[issue18373] let code force str(bytes) to raise an exception

2016-06-17 Thread Daniel Holth
Daniel Holth added the comment: What if we changed it so that Python code could only disable str_bytes() process-wide, editing the original flag? Would that be fatal to debuggers and the repl? -- ___ Python tracker

[issue18373] let code force str(bytes) to raise an exception

2016-05-27 Thread Daniel Holth
Daniel Holth added the comment: Then you prefer the older three year old patch that adds to pystate.h ? http://bugs.python.org/review/18373/#ps8545 I remember not being happy with how complicated it turned out, and perhaps having problems with not wanting the "warn once" behavior? It seems more

[issue18373] let code force str(bytes) to raise an exception

2016-05-27 Thread Daniel Holth
Daniel Holth added the comment: My reasoning was that str(bytes) would normally be called so rarely that who cares. On Fri, May 27, 2016, at 09:02 AM, STINNER Victor wrote: > > STINNER Victor added the comment: > > strbytes.patch of #27134: adding calls to > PyThreadState_GetDict()+PyDict_GetI

[issue18373] let code force str(bytes) to raise an exception

2016-05-27 Thread STINNER Victor
STINNER Victor added the comment: strbytes.patch of #27134: adding calls to PyThreadState_GetDict()+PyDict_GetItemString() seems inefficient for a rare use case I would prefer to modify the existing Py_BytesWarningFlag flag. The flag is process-wide. If it's an issue, we can use a thread-loca

[issue18373] let code force str(bytes) to raise an exception

2016-05-27 Thread Daniel Holth
Daniel Holth added the comment: Better to continue discussion here. Attached is my second, simpler version of the feature. A context manager is included: with string.StrBytesRaises(): str(b'bytes') # raises an exception In a normal program, you might just set the flag to True, but in a l