[issue37367] octal escapes applied inconsistently throughout the interpreter and lib

Terry J. Reedy report at bugs.python.org
Fri Jun 28 17:04:31 EDT 2019


Terry J. Reedy <tjreedy at udel.edu> added the comment:

https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals
says, for \ooo, "In a bytes literal, hexadecimal and octal escapes denote the byte with the given value. In a string literal, these escapes denote a Unicode character with the given value."

I agree that sometimes truncating an invalid integer instead of always raising ValueError is strange.

>>> ord(b'\407')
7
>>> bytes((0o407,))
...
ValueError: bytes must be in range(0, 256)

I don't know is there was an intentional back-compatibility reason for this.

Without an example of re raising, I don't understand the re complaint.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37367>
_______________________________________


More information about the Python-bugs-list mailing list