Open 5j9 opened 7 years ago
There is probably an exception in sitecustomize
, but I don't know how to read the traceback when the application is GUI (i.e. run by pyw
).
This is a bug. Quick fix is to wrap win_unicode_console.enable()
with try:…; except Exception: pass
. I'll make a proper fix eventually.
Thanks.
I guess you already have figured it out, but I had logged the exception before seeing you last comment:
To log the except I used logging
in sitecustomize
:
import win_unicode_console
import logging
logging.basicConfig(filename='pw_error.log',level=logging.DEBUG)
try:
win_unicode_console.enable()
except Exception as e:
logging.exception('Exception:')
And here is the error log:
ERROR:root:Exception:
Traceback (most recent call last):
File "C:\Users\a\AppData\Local\Programs\Python\Python35\lib\site-packages\sitecustomize.py", line 7, in <module>
win_unicode_console.enable()
File "C:\Users\a\AppData\Local\Programs\Python\Python35\lib\site-packages\win_unicode_console\__init__.py", line 28, in enable
streams.enable(stdin=stdin, stdout=stdout, stderr=stderr)
File "C:\Users\a\AppData\Local\Programs\Python\Python35\lib\site-packages\win_unicode_console\streams.py", line 329, in enable
sys.stdout.flush()
AttributeError: 'NoneType' object has no attribute 'flush'
ERROR:root:Exception:
Traceback (most recent call last):
File "C:\Users\a\AppData\Local\Programs\Python\Python35\lib\site-packages\sitecustomize.py", line 7, in <module>
win_unicode_console.enable()
File "C:\Users\a\AppData\Local\Programs\Python\Python35\lib\site-packages\win_unicode_console\__init__.py", line 28, in enable
streams.enable(stdin=stdin, stdout=stdout, stderr=stderr)
File "C:\Users\a\AppData\Local\Programs\Python\Python35\lib\site-packages\win_unicode_console\streams.py", line 329, in enable
sys.stdout.flush()
AttributeError: 'NoneType' object has no attribute 'flush'
Yes, this is one bug. Another one is that the detection mechanisms shouldn't enable the streams at all.
Can you change the readme to include this try except
? Lost some time diagnosing this
@eric-wieser Even better would be to actually fix the bug, by detecting IDLE properly. :-)
@Drekin: Seems that it might just be that pythonw
fails generally - launching idle from the command line with python -m idlelib.idle
works fine, but pythonw -m idlelib.idle
fails
As soon as I put
in
sitecustomize.py
, IDLE won't run anymore (without showing any error message).If I comment out the
#win_unicode_console.enable()
function call (only keeping the import statement) IDLE works again.If I open an IDLE shell, reenable the
win_unicode_console.enable()
, then try to restart the shell, the following error shows up:Another interesting observation is that calling
py "C:\Users\a\AppData\Local\Programs\Python\Python35\Lib\idlelib\idle.pyw"
in cmd works fine and IDLE gets launched. But if I callidle.pyw
usingpyw.exe
(the way the IDLE shortcut works by default) then nothing happens:I'm running
Does anyone know why this is happening?