python-imaging puts a "__init__" module in the top-level module namespace
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-imaging (Ubuntu) |
Fix Released
|
Medium
|
Matthias Klose |
Bug Description
PIL installs a PIL.pth file:
$ cat /usr/lib/
PIL
This means that the contents /usr/lib/
This is clearly buggy, because it means the same modules are importable twice, under different names (and python thinks they are different modules, and so they have different instances of globals):
>>> import Image
>>> PIL.Image
>>> PIL.Image is Image
False
Worse, this makes __init__ importable, which seems to confuse Python's traceback machinery sometimes, leading to tracebacks with weird lines like:
File "/usr/lib/
File "/usr/lib/
This can happen even to code that doesn't actually use PIL; it's mere presence breaks things.
Aside from all this, it's just ugly to add 75 names as top-level modules when one (just the "PIL" package) would do. Ideally the PIL.pth file would just be removed.
I made a copy-and-paste bug with this snippet:
>>> import Image
>>> PIL.Image
>>> PIL.Image is Image
False
Clearly I meant:
>>> import Image
>>> import PIL.Image
>>> PIL.Image is Image
False