@@ -93,7 +93,11 @@ win32_urandom(unsigned char *buffer, Py_ssize_t size, int raise)
9393 return 0 ;
9494}
9595
96- #elif HAVE_GETENTROPY
96+ /* Issue #25003: Don' use getentropy() on Solaris (available since
97+ * Solaris 11.3), it is blocking whereas os.urandom() should not block. */
98+ #elif defined(HAVE_GETENTROPY ) && !defined(sun )
99+ #define PY_GETENTROPY 1
100+
97101/* Fill buffer with size pseudo-random bytes generated by getentropy().
98102 Return 0 on success, or raise an exception and return -1 on error.
99103 If fatal is nonzero, call Py_FatalError() instead of raising an exception
@@ -333,7 +337,7 @@ _PyOS_URandom(void *buffer, Py_ssize_t size)
333337
334338#ifdef MS_WINDOWS
335339 return win32_urandom ((unsigned char * )buffer , size , 1 );
336- #elif HAVE_GETENTROPY
340+ #elif defined( PY_GETENTROPY )
337341 return py_getentropy (buffer , size , 0 );
338342#else
339343# ifdef __VMS
@@ -396,7 +400,7 @@ _PyRandom_Init(void)
396400 (void )win32_urandom ((unsigned char * )secret , secret_size , 0 );
397401#elif __VMS
398402 vms_urandom ((unsigned char * )secret , secret_size , 0 );
399- #elif HAVE_GETENTROPY
403+ #elif defined( PY_GETENTROPY )
400404 (void )py_getentropy (secret , secret_size , 1 );
401405#else
402406 dev_urandom_noraise (secret , secret_size );
@@ -412,7 +416,7 @@ _PyRandom_Fini(void)
412416 CryptReleaseContext (hCryptProv , 0 );
413417 hCryptProv = 0 ;
414418 }
415- #elif HAVE_GETENTROPY
419+ #elif defined( PY_GETENTROPY )
416420 /* nothing to clean */
417421#else
418422 dev_urandom_close ();
0 commit comments