Bug report
Bug description:
I noticed the error messages between magic methods like __int__ and __float__ were inconsistent. This seems like slightly undesirable behavior to me. I used the following code to generate many of them.
classFoo:
def__int__(self):
returnNonedef__float__(self):
returnNonedef__bytes__(self):
returnNonedef__complex__(self):
returnNonedef__bool__(self):
returnNonedef__str__(self):
returnNonetry:
int(Foo())
exceptExceptionase:
print(e)
try:
float(Foo())
exceptExceptionase:
print(e)
try:
bytes(Foo())
exceptExceptionase:
print(e)
try:
complex(Foo())
exceptExceptionase:
print(e)
try:
bool(Foo())
exceptExceptionase:
print(e)
try:
str(Foo())
exceptExceptionase:
print(e)
And the output is as follows:
__int__returnednon-int (type NoneType)
Foo.__float__returnednon-float (type NoneType)
__bytes__returnednon-bytes (type NoneType)
__complex__returnednon-complex (type NoneType)
__bool__shouldreturnbool, returnedNoneType__str__returnednon-string (type NoneType)
The first issue I've made, but seems like a reasonable bug. I'm not sure if there are other "type-conversion" magic methods out there that aren't consistent.
CPython versions tested on:
3.13, 3.12
Operating systems tested on:
Windows
Linked PRs
Bug report
Bug description:
I noticed the error messages between magic methods like
__int__and__float__were inconsistent. This seems like slightly undesirable behavior to me. I used the following code to generate many of them.And the output is as follows:
The first issue I've made, but seems like a reasonable bug. I'm not sure if there are other "type-conversion" magic methods out there that aren't consistent.
CPython versions tested on:
3.13, 3.12
Operating systems tested on:
Windows
Linked PRs