[Python-Dev] Virtualenv not portable from Python 2.7.2 to 2.7.3 (os.urandom missing) (original) (raw)

Carl Meyer carl at oddbird.net
Wed Mar 28 20:48:21 CEST 2012


Hi Jason,

On 03/28/2012 12:22 PM, Jason R. Coombs wrote:

To reproduce, using virtualenv 1.7+ on Python 2.7.2 on Ubuntu, create a virtualenv. Move that virtualenv to a host with Python 2.7.3RC2 yields:

jaraco at vdm-dev:~$ /usr/bin/python2.7 -V Python 2.7.3rc2 jaraco at vdm-dev:~$ env/bin/python -V Python 2.7.2 jaraco at vdm-dev:~$ env/bin/python -c "import os; os.urandom()" Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'urandom' This bug causes Django to not start properly (under some circumstances). I reviewed the changes between v2.7.2 and 2.7 (tip) and it seems there was substantial refactoring of the os and posix modules for urandom. I still don’t fully understand why the urandom method is missing (because the env includes the python 2.7.2 executable and stdlib).

In Python 2.6.8/2.7.3, urandom is built into the executable. A virtualenv doesn't contain the whole stdlib, only the bits necessary to bootstrap site.py. So the problem arises from trying to use the 2.7.3 stdlib with a 2.7.2 interpreter.

I suspect this change is going to cause some significant backward compatibility issues. Is there a recommended workaround? Should I file a bug?

The workaround is easy: just re-run virtualenv on that path with the new interpreter.

I was made aware of this issue a few weeks ago, and added a warning to the virtualenv "news" page: http://www.virtualenv.org/en/latest/news.html I'm not sure where else to publicize it.

Carl

-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature URL: <http://mail.python.org/pipermail/python-dev/attachments/20120328/d40373ed/attachment.pgp>



More information about the Python-Dev mailing list