Terry J. Reedy <tjre...@udel.edu> added the comment:
I can't find who wrote this block treating octal escapes beginning with 4-7 the same as those beginning with 0-3. case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': c = s[-1] - '0'; if (s < end && '0' <= *s && *s <= '7') { c = (c<<3) + *s++ - '0'; if (s < end && '0' <= *s && *s <= '7') c = (c<<3) + *s++ - '0'; } *p++ = c; break; Antoine Pitrou merged from somewhere in 2010 and Christiqn Heimes renamed something in 2008 and before that, ???. Guido wrote the initial bytesobject.c in 2006. Guido, do you agree that the current behavior, treating the same int differently when input into a bytes in different ways, is a bug, and if so, should we backport the fix? >>> b'\407' b'\x07' >>> bytes((0o407,)) Traceback (most recent call last): File "<pyshell#7>", line 1, in <module> bytes((0o407,)) ValueError: bytes must be in range(0, 256) ---------- nosy: +gvanrossum _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37367> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com