View Issue Details

IDProjectCategoryView StatusLast Update
0000831FreeCADBugpublic2012-09-12 06:35
Reportershoogen Assigned To 
Status closedResolutionfixed 
Product Version0.12 
Fixed in Version0.13 
Summary0000831: python print causes File descriptor error on windows
DescriptionThis means that any python module only works on windows if the "Redirect internal python output to report view" Option is enabled. Otherwise as soon as the output buffer of the python interpreter overflows an [Errno 9] Bad file descriptor Exception gets thrown.
If there is no writable STDOUT for the python interpreter the output should be redirected (or discarded) disregarded the setting in the preferences
Additional InformationI consider this a showstopper for the 0.13 release.
TagsNo tags attached.
FreeCAD Information



2012-09-11 10:57

administrator   ~0002382

Does this mean that the default stdout object of Python fails after some time because there is no command line window (shell) where it could write into?
And what's the best way to test this?


2012-09-11 11:24

administrator   ~0002383

Ah, I don't think that this is directly related to Python. It might be rather a certain windows limitation. E.g. if you start a command in the shell with too many arguments (e.g. the compiler with hundreds of files) then you'll get exactly the "bad file descriptor" message.

So, I assume the default Python stdout object writes on the buffer for the shell window (or however Windows does this) and after the buffer is full it generates the error (and empties the buffer). That's probably why we have seen this error only on Windows and never on Linux.

To force this error you only have to execute a Python module with:
print """


2012-09-11 12:12

administrator   ~0002384

When using print() it internally uses the function PyFile_WriteObject which for file objects uses file_PyObject_Print() (and there PyObject_Print() > string_print). In string_print() it checks whether the string exceeds INT_MAX and if so the PyExc_IOError exception is explicitly set by Python.


2012-09-11 16:08

developer   ~0002385

I havened experienced the problem when runing FreeCAD in command line mode. Though the processing is much slower. (maybe because of synchronized output). And even print '#'* (1 << 18) works there


2012-09-11 16:53

developer   ~0002386

From a macro I can print up to 2616 chars (or 2614 + auto \r\n). That is far away from INT_MAX


2012-09-11 17:07

developer   ~0002387


2012-09-12 06:35

administrator   ~0002388

git show dfcee2e

Issue History

Date Modified Username Field Change
2012-09-11 10:25 shoogen New Issue
2012-09-11 10:57 wmayer Note Added: 0002382
2012-09-11 11:24 wmayer Note Added: 0002383
2012-09-11 12:12 wmayer Note Added: 0002384
2012-09-11 16:08 shoogen Note Added: 0002385
2012-09-11 16:53 shoogen Note Added: 0002386
2012-09-11 17:07 shoogen Note Added: 0002387
2012-09-12 06:35 wmayer Note Added: 0002388
2012-09-12 06:35 wmayer Status new => closed
2012-09-12 06:35 wmayer Resolution open => fixed
2012-09-12 06:35 wmayer Fixed in Version => 0.13