[issue33002] Making a class formattable as hex/oct integer with printf-style formatting requires both __int__ and __index__ for no good reason

2019-03-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Resolved in issue36048.

--
nosy: +serhiy.storchaka
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Deprecate implicit truncating when convert Python numbers to C 
integers: use __index__, not __int__

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33002] Making a class formattable as hex/oct integer with printf-style formatting requires both __int__ and __index__ for no good reason

2018-09-23 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33002] Making a class formattable as hex/oct integer with printf-style formatting requires both __int__ and __index__ for no good reason

2018-03-06 Thread Mark Dickinson

Mark Dickinson  added the comment:

Agreed that this seems wrong.

--
nosy: +eric.smith, mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33002] Making a class formattable as hex/oct integer with printf-style formatting requires both __int__ and __index__ for no good reason

2018-03-05 Thread Josh Rosenberg

Josh Rosenberg  added the comment:

To be clear, this is a problem with old-style (printf-style) formatting, and 
applies to both bytes formatting and str formatting. So a class like:

class Foo:
def __index__(self):
return 1

will fail with a TypeError should you do any of:

'%o' % Foo()
'%x' % Foo()
'%X' % Foo()
b'%o' % Foo()
b'%x' % Foo()
b'%X' % Foo()

even though hex(Foo()) and oct(Foo()) work without issue.

--
title: Making a class formattable as hex/oct integer requires both __int__ and 
__index__ for no good reason -> Making a class formattable as hex/oct integer 
with printf-style formatting requires both __int__ and __index__ for no good 
reason

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com