[issue30894] Python 3.6.1 String Literal Error Not Going to sys.stderr
George Gillan
report at bugs.python.org
Mon Jul 10 17:07:26 EDT 2017
New submission from George Gillan:
Python 3.6.1 String Literal Error Not Going to sys.stderr
Using Windows 7 and Python 3.6.1. Attempting to redirect sys.stderr to a file. The application will be deployed via .pyw file instead of .py so the GUI application runs without a console window.
Is this fixable or 'as-is' due to the nature of the way the interpreter scans the code?
The following code worked as intended.
#!/usr/bin/env python3.6
errfile = 'test_err.txt'
import sys
errorlog = open(errfile, 'w')
sys.stderr = errorlog
1/0
The code above produced a file called test_err.txt with the following contents:
Traceback (most recent call last):
File "C:\Users\George\Coding\Python\test\mintest.py", line 8, in <module>
1/0
ZeroDivisionError: division by zero
The following code did not work as intended.
#!/usr/bin/env python3.6
errfile = 'test_err.txt'
import sys
errorlog = open(errfile, 'w')
sys.stderr = errorlog
print("test)
The code above did not create the file test_err.txt with the error going to the console window instead.
Copy-paste from the Windows console.
The successful test (first) showed nothing in the console window; the error was logged to the file as noted above. The unsuccessful test (second) did not create the file, instead the error was sent to the console.
C:\Users\George\Coding\Python\test>mintest
C:\Users\George\Coding\Python\test>mintest
File "C:\Users\George\Coding\Python\test\mintest.py", line 8
print("test)
^
SyntaxError: EOL while scanning string literal
C:\Users\George\Coding\Python\test>
PS: This is my first bug/issue submission here. Please coach me as needed if I messed it up.
----------
components: Interpreter Core
files: Python361_bug.txt
messages: 298083
nosy: George Gillan
priority: normal
severity: normal
status: open
title: Python 3.6.1 String Literal Error Not Going to sys.stderr
type: behavior
versions: Python 3.6
Added file: http://bugs.python.org/file47001/Python361_bug.txt
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30894>
_______________________________________
More information about the Python-bugs-list
mailing list