scap1784 / dpkt

Automatically exported from code.google.com/p/dpkt
Other
0 stars 0 forks source link

dynamic module loading too careless #34

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If pigment python is installed, dpkt 1.7 fails with the error below:

Traceback (most recent call last):
  File "./setup.py", line 4, in <module>
    import dpkt
  File "/usr/obj/i386/py-dpkt-1.7/dpkt-1.7/dpkt/__init__.py", line 24, in <module>
    import ethernet
  File "/usr/obj/i386/py-dpkt-1.7/dpkt-1.7/dpkt/ethernet.py", line 128, in <module>
    __load_types()
  File "/usr/obj/i386/py-dpkt-1.7/dpkt-1.7/dpkt/ethernet.py", line 122, in __load_types
    mod = __import__(modname, g)
  File "/usr/obj/i386/py-dpkt-1.7/dpkt-1.7/dpkt/ip6.py", line 95, in <module>
    import ip
  File "/usr/obj/i386/py-dpkt-1.7/dpkt-1.7/dpkt/ip.py", line 255, in <module>
    __load_protos()
  File "/usr/obj/i386/py-dpkt-1.7/dpkt-1.7/dpkt/ip.py", line 252, in __load_protos
    IP.set_proto(v, getattr(mod, name.upper()))
AttributeError: 'module' object has no attribute 'PGM'

This was found in OpenBSD 4.7/x86 but the error is not OS specific.
Attached diff should fix it.
Thanks.

Original issue reported on code.google.com by federico...@gmail.com on 20 Jun 2010 at 2:02

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Suggested solution is not good, because it will just mask the problem.  Better 
to add level=1 parameter to all imports (see diff).

Original comment by e.najda...@gmail.com on 12 May 2012 at 2:55

Attachments:

GoogleCodeExporter commented 9 years ago
changing the line to 
                mod = __import__('dpkt.{}'.format(name), g)
should also fix it...

Original comment by ki...@kiddaland.net on 16 Dec 2013 at 9:22