Created
October 10, 2012 16:24
-
-
Save babo/3866694 to your computer and use it in GitHub Desktop.
python os.py difference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 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