[IronPython] tempfile.mkstemp gives bad file descriptor?

Slide slide.o.mix at gmail.com
Sun Mar 6 05:24:06 CET 2011


For some reason, I am now getting the following error when running the
unit tests for the csv module.

======================================================================
ERROR: test_write_simple_dict (__main__.TestDictFields)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\acearl\Code\IronLanguages\External.LCA_RESTRICTED\Languages\Iro
nPython\27\Lib\test\test_csv.py", line 598, in test_write_simple_dict
    fd, name = tempfile.mkstemp()
OSError: [Errno 9] Bad file descriptor

----------------------------------------------------------------------
Ran 80 tests in 2.774s

FAILED (errors=1)
Traceback (most recent call last):
  File "C:\Users\acearl\Code\IronLanguages\External.LCA_RESTRICTED\Languages\Iro
nPython\27\Lib\test\test_csv.py", line 1054, in <module>
  File "C:\Users\acearl\Code\IronLanguages\External.LCA_RESTRICTED\Languages\Iro
nPython\27\Lib\test\test_csv.py", line 1049, in test_main
  File "C:\Users\acearl\Code\IronLanguages\External.LCA_RESTRICTED\Languages\Iro
nPython\27\Lib\test\test_support.py", line 1078, in run_unittest
  File "C:\Users\acearl\Code\IronLanguages\External.LCA_RESTRICTED\Languages\Iro
nPython\27\Lib\test\test_support.py", line 1061, in _run_suite
test.test_support.TestFailed: Traceback (most recent call last):
  File "C:\Users\acearl\Code\IronLanguages\External.LCA_RESTRICTED\Languages\Iro
nPython\27\Lib\test\test_csv.py", line 598, in test_write_simple_dict
    fd, name = tempfile.mkstemp()
OSError: [Errno 9] Bad file descriptor


The error occurs on the following code

fd, name = tempfile.mkstemp()
fileobj = io.open(fd, 'w+b')

There are several other occurences of tempfile.mkstemp and then
os.fdopen. This is the only one that uses io.open. I am not sure why
they use io.open in this case. If I replace the io.open with
os.fdopen, it works as expected. At the point in PythonFile where it
calls objMapping.GetObjectFromId, there is nothing in the mapping
dictionary, it is completely empty.

I am unfamiliar with all the internals still, but I will try and
discover what is going on. Seems like this could be a bug.

Thanks,

slide

-- 
slide-o-blog
http://slide-o-blog.blogspot.com/



More information about the Ironpython-users mailing list