[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2017-03-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset c2cf12857187aa147c268651f10acd6da2c9cb74 by Serhiy Storchaka in branch 'master': bpo-8256: Fixed possible failing or crashing input() (#517) https://github.com/python/cpython/commit/c2cf12857187aa147c268651f10acd6da2c9cb74 --

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2017-03-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset a16894ebf8823f0e09036aacde9288c00e8d9058 by Serhiy Storchaka in branch '3.5': [3.5] bpo-8256: Fixed possible failing or crashing input() (#642) https://github.com/python/cpython/commit/a16894ebf8823f0e09036aacde9288c00e8d9058 --

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2017-03-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset aac875fa2f03cab61ceeaa2621c4c5534c7bcfc2 by Serhiy Storchaka in branch '3.6': [3.6] bpo-8256: Fixed possible failing or crashing input() (#641) https://github.com/python/cpython/commit/aac875fa2f03cab61ceeaa2621c4c5534c7bcfc2 --

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2017-03-17 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2017-03-17 Thread Larry Hastings
Changes by Larry Hastings : -- pull_requests: +577 ___ Python tracker ___ ___

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2017-03-12 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- pull_requests: +531 ___ Python tracker ___ ___

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2017-03-12 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- pull_requests: +530 ___ Python tracker ___ ___

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2017-03-12 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- pull_requests: +529 ___ Python tracker ___ ___

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2017-03-06 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- pull_requests: +427 ___ Python tracker ___ ___

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2017-03-06 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- versions: +Python 3.7 -Python 3.4 ___ Python tracker ___

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2015-11-23 Thread Erik Bray
Erik Bray added the comment: I just recently discovered this myself. In the process of debugging the issue I also noticed the same bug that is now fixed via Issue 24402. While I agree that Issue 24402 mostly mitigates the issue I think this patch is still worthwhile, as the current behavior

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2015-11-23 Thread Erik Bray
Erik Bray added the comment: > I think the above code *should* break Actually, I see now that Serhiy's patch would allow this example to just pass through to the non-interactive fallback. So I take it back that my example should break--I think using the fallback would also be fine.

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2015-10-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here is a patch. -- stage: needs patch -> patch review Added file: http://bugs.python.org/file40704/input_fallback.patch ___ Python tracker

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2015-10-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I would fallback to PyFile_WriteObject(prompt, fout, Py_PRINT_RAW) if the stdout has no the encoding attribute or it is not a string. -- nosy: +serhiy.storchaka versions: +Python 3.4, Python 3.5, Python 3.6 -Python 3.2, Python 3.3

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2015-10-06 Thread Martin Panter
Martin Panter added the comment: Serhiy, your patch looks like a worthwhile improvement because it adds proper error checking and handling. However I suspect this original bug is actually a side effect of Issue 24402. The code in question shouldn’t even be running, because sys.stdout is not

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2012-08-26 Thread aliles
aliles added the comment: Upload new patch that uses encoding and errors from stderr if stdout values are invalid unicode. Includes unit test in test_builtin.py. With this patch I am no longer able to replicate this issue. -- Added file:

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2012-08-22 Thread aliles
aliles added the comment: Replicated this issue on Python 3.3b2. The cause is the 'encoding' and 'errors' attributes on io.StringIO() being None. Doctest replaces sys.stdout with a StringIO subclass. The exception raised is still a TypeError. At this point I'm unsure what the fix should be:

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2012-08-22 Thread Antoine Pitrou
Antoine Pitrou added the comment: I suggest that since PyOS_Readline() write the prompt to stderr, the conversion uses the encoding of stderr. Agreed with Amaury. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2011-11-03 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: A patch similar to input_stdout_encoding.patch has been applied to 3.2 and 3.3 for the issue #6697: see changeset 846866aa0eb6. -- ___ Python tracker rep...@bugs.python.org

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2011-11-03 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: input_stdout_none_encoding.patch uses UTF-8 if sys.stdout.encoding is None. -- Added file: http://bugs.python.org/file23608/input_stdout_none_encoding.patch ___ Python tracker

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2011-10-28 Thread Florent Xicluna
Florent Xicluna florent.xicl...@gmail.com added the comment: Confirmed in 3.3. The patch does not apply cleanly on trunk. -- stage: test needed - needs patch versions: +Python 3.3 -Python 3.1 ___ Python tracker rep...@bugs.python.org

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2010-05-14 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: since the prompt is written to stderr, why is sys.stdout.encoding used instead of sys.stderr.encoding? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8256

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2010-05-14 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: amaury since the prompt is written to stderr, why is sys.stdout.encoding amaury used instead of sys.stderr.encoding? input() calls PyOS_Readline() but PyOS_Readline() has multiple implementations: - PyOS_StdioReadline() if

[issue8256] input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None

2010-05-13 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Here is a patch catching the _PyUnicode_AsString() error. input() uses sys.stdout.encoding to encode the prompt to a byte string, but PyOS_StdioReadline() writes the prompt to stderr (it should use sys_stdout). I don't know which