This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients Jeffrey.Kintscher, bup, ezio.melotti, gvanrossum, mrabarnett, serhiy.storchaka, taleinat, terry.reedy
Date 2019-11-20.04:13:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1574223235.32.0.756680611477.issue37367@roundup.psfhosted.org>
In-reply-to
Content
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)
History
Date User Action Args
2019-11-20 04:13:55terry.reedysetrecipients: + terry.reedy, gvanrossum, taleinat, ezio.melotti, mrabarnett, serhiy.storchaka, bup, Jeffrey.Kintscher
2019-11-20 04:13:55terry.reedysetmessageid: <1574223235.32.0.756680611477.issue37367@roundup.psfhosted.org>
2019-11-20 04:13:55terry.reedylinkissue37367 messages
2019-11-20 04:13:55terry.reedycreate