Skip to content

Commit a92941f

Browse files
authored
pythoninfo: ignore OSError(ENOSYS) on getrandom() (#3655)
1 parent 865e4b4 commit a92941f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Lib/test/pythoninfo.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Collect various informations about Python to help debugging test failures.
33
"""
44
from __future__ import print_function
5+
import errno
56
import re
67
import sys
78
import traceback
@@ -223,11 +224,17 @@ def format_attr(attr, value):
223224
if hasattr(os, 'getrandom'):
224225
# PEP 524: Check if system urandom is initialized
225226
try:
226-
os.getrandom(1, os.GRND_NONBLOCK)
227-
state = 'ready (initialized)'
228-
except BlockingIOError as exc:
229-
state = 'not seeded yet (%s)' % exc
230-
info_add('os.getrandom', state)
227+
try:
228+
os.getrandom(1, os.GRND_NONBLOCK)
229+
state = 'ready (initialized)'
230+
except BlockingIOError as exc:
231+
state = 'not seeded yet (%s)' % exc
232+
info_add('os.getrandom', state)
233+
except OSError as exc:
234+
# Python was compiled on a more recent Linux version
235+
# than the current Linux kernel: ignore OSError(ENOSYS)
236+
if exc.errno != errno.ENOSYS:
237+
raise
231238

232239

233240
def collect_readline(info_add):

0 commit comments

Comments
 (0)