Bugs item #2993756, was opened at 2010-04-28 14:44
Message generated for change (Comment added) made by goodger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=422030&aid=2993756&group_id=38414
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Invalid
Priority: 5
Private: No
Submitted By: Jared ()
Assigned to: Nobody/Anonymous (nobody)
Summary: PIL import error
Initial Comment:
Docutils uses "import Image" to use the Python Imaging Library, which conflicts with django's "from PIL import Image" (essentially the module is imported twice and chokes. See this post http://jaredforsyth.com/blog/2010/apr/28/accessinit-hash-collision-3-both-1-and-1/ for more info).
I've attached a patch which fixes this problem.
----------------------------------------------------------------------
>Comment By: David Goodger (goodger)
Date: 2010-04-28 16:08
Message:
The PIL docs
(http://www.pythonware.com/library/pil/handbook/introduction.htm) say to
use "import Image".
If we change Docutils, it may just break somebody else's code. Closing as
"invalid": this is a PIL problem.
Try this workaround in your own code (import PIL.Image once in advance,
and make multiple references in Python's modules table):
>>> import sys
>>> import PIL.Image
>>> sys.modules['Image'] = PIL.Image
>>> import Image
>>> from PIL import Image as Image2
>>> id(Image)
9901296
>>> id(PIL.Image)
9901296
>>> id(Image2)
9901296
----------------------------------------------------------------------
Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2010-04-28 15:34
Message:
PIL has long had this split personality, where it tries to support both
ways of using it. (This is an insane behavior on PIL's part.)
Apps I'm involved in use "from PIL import Image".
I've no hope that PIL will ever be changed to require one or the other
uses, and I'm not sure I would advocate doing so, because either is likely
to break some non-trivial number of apps.
----------------------------------------------------------------------
Comment By: David Goodger (goodger)
Date: 2010-04-28 15:25
Message:
Can you provide some evidence please? A URL to an authoritative doc would
be best.
Your blog post refers to three projects, two of which use the
"non-standard" form... which pre-date the project using the "standard"
form. I'm leaning toward "won't fix".
----------------------------------------------------------------------
Comment By: Jared ()
Date: 2010-04-28 15:15
Message:
>From looking around, I have determined that "from PIL import Image" is the
more accepted, standard usage. I would also hope to change PIL such that
"import Image" would be impossible, but indeed that seems unlikely to
happen.
Although whichever way docutils implements there will still be a way to
break it, would suggest working toward standardization.
----------------------------------------------------------------------
Comment By: David Goodger (goodger)
Date: 2010-04-28 15:07
Message:
Perhaps it's Django that's the real problem? Or PIL/Image itself? (Or maybe
an import problem in Python?)
If we fix this here, won't projects that use Docutils and also do "import
Image" see the same problem?
I'd like to see some justification as to why this is problem for Docutils
to fix.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=422030&aid=2993756&group_id=38414
|