[issue18965] 2to3 can produce illegal bytes literals

Serhiy Storchaka report at bugs.python.org
Sun Sep 8 02:06:39 CEST 2013


New submission from Serhiy Storchaka:

In Python 2 string literals are allowed to contain non-ascii characters. In Python 3 bytes literals can contains only ascii characters, non-ascii characters should be escaped with \xXX. However 2to3 doesn't change b'...' literals and produces illegal code.

I propose new fixer which escapes non-ascii bytes in bytes literals. Here is a patch (without tests yet).

----------
components: 2to3 (2.x to 3.x conversion tool)
files: 2to3_nonascii_bytes.patch
keywords: patch
messages: 197205
nosy: serhiy.storchaka, vinay.sajip
priority: normal
severity: normal
stage: patch review
status: open
title: 2to3 can produce illegal bytes literals
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file31657/2to3_nonascii_bytes.patch

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


More information about the Python-bugs-list mailing list