View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0000831||FreeCAD||Bug||public||2012-09-11 10:25||2012-09-12 06:35|
|Fixed in Version||0.13|
|Summary||0000831: python print causes File descriptor error on windows|
|Description||This 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 Information||I consider this a showstopper for the 0.13 release.|
|Tags||No tags attached.|
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?
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:
COPY SOME VERY LONG TEXT HERE
||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.|
||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|
||From a macro I can print up to 2616 chars (or 2614 + auto \r\n). That is far away from INT_MAX|
||git show dfcee2e|
|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|