Author ethan.furman
Recipients ethan.furman, gvanrossum, mark.dickinson, pitrou, rhettinger, serhiy.storchaka, skrah
Date 2013-12-16.10:29:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1387189744.09.0.921617360417.issue19995@psf.upfronthosting.co.za>
In-reply-to
Content
Using Enum to illustrate:

    --> class Grade(enum.Enum):
    ...   A = 4
    ...   B = 3
    ...   C = 2
    ...   D = 1
    ...   F = 0
    ...   def __index__(self):
    ...     return self._value_

    --> ['miserable'][Grade.F]
    'miserable'

    --> '%x' % Grade.F
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: %x format: a number is required, not Grade

    --> hex(Grade.F)
    '0x0'

I suggest that hex() and oct() have the same check that %x and %o do so that non-numbers are not representable as hex and octal.  

While we're at it, we should do the same for bin().  Are there any others?

I'll create a patch once we have a decision on which way to solve this issue.
History
Date User Action Args
2013-12-16 10:29:04ethan.furmansetrecipients: + ethan.furman, gvanrossum, rhettinger, mark.dickinson, pitrou, skrah, serhiy.storchaka
2013-12-16 10:29:04ethan.furmansetmessageid: <1387189744.09.0.921617360417.issue19995@psf.upfronthosting.co.za>
2013-12-16 10:29:04ethan.furmanlinkissue19995 messages
2013-12-16 10:29:03ethan.furmancreate