Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r97285:a6c1ae01424e
Date: 2019-08-26 22:31 +0200
http://bitbucket.org/pypy/pypy/changeset/a6c1ae01424e/

Log:    CPython raises NotImplementedError if /dev/urandom cannot be found.
        To maximize compatibility, we should also raise NotImplementedError
        and not OSError (although CPython also raises OSError in case it
        could open /dev/urandom but there are further problems).

diff --git a/pypy/module/posix/interp_posix.py 
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -1351,7 +1351,12 @@
         _sigcheck.space = space
         return space.newbytes(rurandom.urandom(context, n, _signal_checker))
     except OSError as e:
-        raise wrap_oserror(space, e)
+        # CPython raises NotImplementedError if /dev/urandom cannot be found.
+        # To maximize compatibility, we should also raise NotImplementedError
+        # and not OSError (although CPython also raises OSError in case it
+        # could open /dev/urandom but there are further problems).
+        raise wrap_oserror(space, e,
+            w_exception_class=space.w_NotImplementedError)
 
 def ctermid(space):
     """ctermid() -> string
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to