Skip to content

Instantly share code, notes, and snippets.

@babo
Created October 10, 2012 16:24
Show Gist options
  • Save babo/3866694 to your computer and use it in GitHub Desktop.
Save babo/3866694 to your computer and use it in GitHub Desktop.
python os.py difference
--- python2.6/os.py 2010-04-16 16:41:14.000000000 +0200
+++ /usr/lib/python2.6/os.py 2012-10-02 00:31:53.000000000 +0200
@@ -742,22 +742,3 @@
_make_statvfs_result)
except NameError: # statvfs_result may not exist
pass
-
-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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment