Issue #18756: Improve error reporting in os.urandom() when the failure is due to something else than /dev/urandom not existing.
diff --git a/Python/random.c b/Python/random.c
index 825260f..73e3cc3 100644
--- a/Python/random.c
+++ b/Python/random.c
@@ -165,8 +165,12 @@
     Py_END_ALLOW_THREADS
     if (fd < 0)
     {
-        PyErr_SetString(PyExc_NotImplementedError,
-                        "/dev/urandom (or equivalent) not found");
+        if (errno == ENOENT || errno == ENXIO ||
+            errno == ENODEV || errno == EACCES)
+            PyErr_SetString(PyExc_NotImplementedError,
+                            "/dev/urandom (or equivalent) not found");
+        else
+            PyErr_SetFromErrno(PyExc_OSError);
         return -1;
     }