Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:olh:SLE_11
python-base
python-2.6.8-restore-os.urandom.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File python-2.6.8-restore-os.urandom.patch of Package python-base
Index: Python-2.6.8/Lib/os.py =================================================================== --- Python-2.6.8.orig/Lib/os.py 2012-04-10 17:32:05.000000000 +0200 +++ Python-2.6.8/Lib/os.py 2012-04-24 16:51:27.000000000 +0200 @@ -742,3 +742,25 @@ _make_statvfs_result) except NameError: # statvfs_result may not exist pass + +# compatibility for broken apps that use older interpreter than stdlib +# (this might be because of static-linked libpython, or private copy +# of interpreter binary, as in virtualenv) +if not _exists("urandom"): + def urandom(n): + """urandom(n) -> str + + Return a string of n random bytes suitable for cryptographic use. + + """ + import warnings + warnings.warn("Interpreter/stdlib version mismatch. Your interpreter can't do hash randomization. Make sure you are running an up-to-date version.", RuntimeWarning) + try: + _urandomfd = open("/dev/urandom", O_RDONLY) + except: + raise NotImplementedError("/dev/urandom (or equivalent) not found") + bytes = "" + while len(bytes) < n: + bytes += read(_urandomfd, n - len(bytes)) + close(_urandomfd) + return bytes
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor