This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author waynesong
Recipients waynesong
Date 2015-01-05.21:12:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1420492361.28.0.389548963786.issue23172@psf.upfronthosting.co.za>
In-reply-to
Content
The following script:

import os
import resource
import random

print("1")

for fd in range(resource.getrlimit(resource.RLIMIT_NOFILE)[0]):
    try:
        if fd not in range(0, 3):
            os.close(fd)
    except os.error:
        pass

print("2")
print(os.urandom(32))
print("3")

Crashes with the following output:

1
2
Traceback (most recent call last):
  File "test.py", line 17, in <module>
    print(os.urandom(32))
OSError: [Errno 9] Bad file descriptor

On an Ubuntu 14.04 install (in VirtualBox).  It seems to run correctly on Mac OS X.  The script runs fine if I don't import random at the top.
History
Date User Action Args
2015-01-05 21:12:41waynesongsetrecipients: + waynesong
2015-01-05 21:12:41waynesongsetmessageid: <1420492361.28.0.389548963786.issue23172@psf.upfronthosting.co.za>
2015-01-05 21:12:41waynesonglinkissue23172 messages
2015-01-05 21:12:41waynesongcreate