New submission from Dan Snider <mr.assume.a...@gmail.com>:

>>> b'\542\571\564\545\563', b'\142\171\164\145\163'
(b'bytes', b'bytes')

All the C compilers I know of at the very least generate a warning when one 
tries to assign an oct literal >= '\400' to a byte. And that's because it's 
nonsense when bytes have 8 bits, even more so for an 8 bit byte string.

The literal value:

>>> b'\542\571\564\545\563'

should be identical to:

>>> bytes([0o542, 0o571, 0o564, 0o545, 0o563])

That obviously doesn't work:

>>> b'\542\571\564\545\563' == bytes([0o542, 0o571, 0o564, 0o545, 0o563])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: bytes must be in range(0, 256)

This is on Windows/Intel. I haven't looked at the parser in much detail, but I 
wonder what would happen on a big-endian system?

----------
components: Interpreter Core, Windows
messages: 324918
nosy: bup, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Octal byte literals with a decimal value > 255 are silently truncated
type: behavior
versions: Python 3.6, Python 3.7

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

Reply via email to