/usr/share/pyshared/spyderlib/pil_patch.py is in python-spyderlib 2.1.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | # -*- coding: utf-8 -*-
#
# Copyright © 2011 Pierre Raybaut
# Licensed under the terms of the MIT License
# (see spyderlib/__init__.py for details)
"""
Patching PIL (Python Imaging Library) to avoid triggering the error:
AccessInit: hash collision: 3 for both 1 and 1
This error is occuring because of a bug in the PIL import mechanism.
How to reproduce this bug in a standard Python interpreter outside Spyder?
By importing PIL by two different mechanisms
Example on Windows:
===============================================================================
C:\Python27\Lib\site-packages>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import Image
>>> from PIL import Image
AccessInit: hash collision: 3 for both 1 and 1
===============================================================================
Another example on Windows (actually that's the same, but this is the exact
case encountered with Spyder when the global working directory is the
site-packages directory):
===============================================================================
C:\Python27\Lib\site-packages>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
>>> from pylab import *
AccessInit: hash collision: 3 for both 1 and 1
===============================================================================
The solution to this fix is the following patch:
===============================================================================
C:\Python27\Lib\site-packages>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import Image
>>> import PIL
>>> PIL.Image = Image
>>> from PIL import Image
>>>
===============================================================================
"""
import Image
import PIL
PIL.Image = Image
|