Pablo Galindo Salgado <pablog...@gmail.com> added the comment:

round() delegates to class.__round__, so what's happening here is that numpy's 
float implements __round__ in a way it returns a float.

There is no restriction on what the class can return:

>>> class A:
...     def __round__(self):
...         return "Oh, no!"
...
>>> round(A())
'Oh, no!'

Making additional restrictions is backwards incompatible. Maybe we should add 
something in the docs regarding the no-restriction point.

----------
nosy: +pablogsal

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36879>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to