[issue6697] Check that _PyUnicode_AsString() result is not NULL

STINNER Victor report at bugs.python.org
Fri Mar 5 13:56:17 CET 2010


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

Patch for pythonrun.c:
 - catch _PyUnicode_AsString() error in get_codeset(): very unlikely, codeset is the result of nl_langinfo() and is ASCII only
 - catch _PyUnicode_AsString(sys.stdin.encoding) error in PyRun_InteractiveOneFlags()
 - use _PyUnicode_AsStringOrDefault() for ps1 and ps2: use ps1="" and/or ps2="" on unicode error. I don't know if it's the best option. Display the error is maybe a better idea.

It's possible to raise to test the error on sys.stdin.encoding by adding the following lines to site.py:

class Stdin: pass
sys.stdin = Stdin()
sys.stdin = "\xdc80"

See also #8070: PyRun_InteractiveLoopFlags() doesn't handle errors :-/

----------
Added file: http://bugs.python.org/file16461/pythonrun-py3k.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6697>
_______________________________________


More information about the Python-bugs-list mailing list