Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add this to the end of ``. This fixes the "from os import urandom as _urandom ImportError: cannot import name urandom" issue.
if not _exists("urandom"):
def urandom(n):
"""urandom(n) -> str
Return a string of n random bytes suitable for cryptographic use.
_urandomfd = open("/dev/urandom", O_RDONLY)
except (OSError, IOError):
raise NotImplementedError("/dev/urandom (or equivalent) not found")
bs = b""
while n - len(bs) >= 1:
bs += read(_urandomfd, n - len(bs))
return bs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.