Fulfill Martin's request to use try/except rather than a "look before

you leap" approach.  Makes the early call to os.urandom() unnecessary.
This commit is contained in:
Raymond Hettinger 2004-09-05 00:00:42 +00:00
parent c4536a1dea
commit c1c43cad63
2 changed files with 13 additions and 18 deletions

View file

@ -495,7 +495,11 @@ def test_main(verbose=None):
TestDistributions,
TestModule]
if random._urandom is not None:
try:
random.HardwareRandom().random()
except NotImplementedError:
pass
else:
testclasses.append(HardwareRandom_TestBasicOps)
test_support.run_unittest(*testclasses)