On Wed, Nov 3, 2021 at 11:09 AM Steven D'Aprano <st...@pearwood.info> wrote: > > On Wed, Nov 03, 2021 at 03:03:54AM +1100, Chris Angelico wrote: > > On Wed, Nov 3, 2021 at 1:06 AM Petr Viktorin <encu...@gmail.com> wrote: > > > Let me know if it's clear in the newest version, with this note: > > > > > > > Here, ``encoding: unicode_escape`` in the initial comment is an encoding > > > > declaration. The ``unicode_escape`` encoding instructs Python to treat > > > > ``\u0027`` as a single quote (which can start/end a string), ``\u002c`` > > > > as > > > > a comma (punctuator), etc. > > > > > > > Huh. Is that level of generality actually still needed? Can Python > > deprecate all but a small handful of encodings? > > To be clear, are you proposing to deprecate the encodings *completely* > or just as the source code encoding?
Only source code encodings. Obviously we still need to be able to cope with all manner of *data*, but Python source code shouldn't need to be in bizarre, weird encodings. (Honestly, I'd love to just require that Python source code be UTF-8, but that would probably cause problems, so mandating that it be one of a small set of encodings would be a safer option.) > Personally, I think that using obscure encodings as the source encoding > is one of those "linters and code reviews should check it" issues. > > Besides, now that I've learned about this unicode_escape encoding, I > think that's going to be *awesome* for winning obfuscated Python > competitions! *wink* TBH, I'm not entirely sure how valid it is to talk about *security* considerations when we're dealing with Python source code and variable confusions, but that's a term that is well understood. But to the extent that it is a security concern, it's not one that linters can really cope with. I'm not sure how a linter would stop someone from publishing code on PyPI that causes confusion by its character encoding, for instance. ChrisA _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/HJ452KNBAFXI6WBQ6OUMHHZRRETPC7QL/ Code of Conduct: http://python.org/psf/codeofconduct/