Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9e43acf2
Commit
9e43acf2
authored
Jul 04, 2005
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug #1177468: don't cache /dev/urandom file descriptor in os.urandom
parent
290f3829
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
8 deletions
+7
-8
Lib/os.py
Lib/os.py
+4
-8
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/os.py
View file @
9e43acf2
...
...
@@ -715,22 +715,18 @@ except NameError: # statvfs_result may not exist
pass
if
not
_exists
(
"urandom"
):
_urandomfd
=
None
def
urandom
(
n
):
"""urandom(n) -> str
Return a string of n random bytes suitable for cryptographic use.
"""
global
_urandomfd
if
_urandomfd
is
None
:
try
:
_urandomfd
=
open
(
"/dev/urandom"
,
O_RDONLY
)
except
:
_urandomfd
=
NotImplementedError
if
_urandomfd
is
NotImplementedError
:
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
Misc/NEWS
View file @
9e43acf2
...
...
@@ -150,6 +150,9 @@ Extension Modules
Library
-------
-
Bug
#
1177468
:
Don
't cache the /dev/urandom file descriptor for os.urandom,
as this can cause problems with apps closing all file descriptors.
- Bug #839151: Fix an attempt to access sys.argv in the warnings module
though this can be missing in embedded interpreters
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment