Package: python2.7-minimal Version: 2.7.3-6 Severity: normal Tags: patch Greetings,
When a program ([pyroscope] in my precise case) needs to use /usr/lib/python2.7/random.py, it fails to import urandom. [pyroscope]: https://code.google.com/p/pyroscope/ Here's the error message: File "/usr/lib/python2.7/random.py", line 47, in <module> from os import urandom as _urandom ImportError: cannot import name urandom That's because /usr/lib/python2.7/os.py contains no such definition. Appending the following to os.py fixes the issue: --- >8 --- if not _exists("urandom"): def urandom(n): """urandom(n) -> str Return a string of n random bytes suitable for cryptographic use. """ try: _urandomfd = open("/dev/urandom", O_RDONLY) except (OSError, IOError): raise NotImplementedError("/dev/urandom (or equivalent) not found") try: bs = b"" while n - len(bs) >= 1: bs += read(_urandomfd, n - len(bs)) finally: close(_urandomfd) return bs --- 8< --- Cheers, -- System Information: Debian Release: 7.0 APT prefers stable APT policy: (500, 'stable'), (50, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 3.2.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages python2.7-minimal depends on: ii libc6 2.13-38 ii libgcc1 1:4.7.2-5 ii libssl1.0.0 1.0.1e-2 ii zlib1g 1:1.2.7.dfsg-13 Versions of packages python2.7-minimal recommends: ii python2.7 2.7.3-6 Versions of packages python2.7-minimal suggests: pn binfmt-support <none> -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org