New submission from Daniel Holth:

When I discovered str(b'bytes') in my Python 3 program was causing errors to be 
serialized to disk, I was unhappy. It turns out there is a command line option 
to turn it off, but the vulnerable serialization code is not going to be able 
to set that argument; or the one-argument-per-shebang limit we have in Linux 
was already used for something else.

Instead, provide a threadlocal variable that causes str(bytes) to raise. A 
context manager makes it simple to use for just a portion of your code:

with string.StrBytesRaises():
   no_str_bytes_here()

If not set or False then Python behaves as before.

----------
components: Unicode
files: strbytes.patch
keywords: patch
messages: 266465
nosy: dholth, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: allow str(bytes) raises an exception to be controlled programmatically
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file43024/strbytes.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27134>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to