Skip to content

Make Exceptions more verbose #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

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