Skip to content

Conversation

@muelli
Copy link
Contributor

@muelli muelli commented Apr 9, 2012

So it helps to debug the issues arising.

The tests pass so I think the modifications made are correct.

Tobias Mueller added 6 commits April 9, 2012 18:27
This allows running the test module without manually having to update
the PYTHONPATH. The recommended way, however, to run the tests is:
python2 -m unittest pgpdump.test
This changes the interface of the function but I don't want to replicate
that function in all the filters that I apply on top of the parsed data.
My usecase is smth like this:
    for filename in sys.argv[1:]:
        for packet in ifilter(filter, parsefile(filename)):
            print(packet)
I was hesitating to add this, because it's a calculation that is not
necessarily needed by the user of pgpdump. But then again, that is the
case for nearly every data computed by pgpdump. It'd probably be smart
to make all fields needing calculation a lazy Property() and update the
fields after calculation.
I introduced a NameError at some stage:
  File "/home/muelli/vcs/python-pgpdump/pgpdump/__main__.py", line 13, in parsefile
    for packet in data.packets():
  File "/home/muelli/vcs/python-pgpdump/pgpdump/data.py", line 34, in packets
    total_length, packet = construct_packet(self.data, offset)
  File "/home/muelli/vcs/python-pgpdump/pgpdump/packet.py", line 590, in construct_packet
    packet = PacketType(tag, name, new, packet_data)
  File "/home/muelli/vcs/python-pgpdump/pgpdump/packet.py", line 148, in __init__
    super(SignaturePacket, self).__init__(*args, **kwargs)
  File "/home/muelli/vcs/python-pgpdump/pgpdump/packet.py", line 22, in __init__
    self.parse()
  File "/home/muelli/vcs/python-pgpdump/pgpdump/packet.py", line 166, in parse
    "%02x" % (offset, data[offset]))
NameError: global name 'data' is not defined

It should have been self.data of course.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant