[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__
Mark Dickinson
report at bugs.python.org
Thu Dec 9 04:06:53 EST 2021
Mark Dickinson <dickinsm at gmail.com> added the comment:
@arhadthedev: Thanks for highlighting the issue.
> we need to check if the problem really has place and the PR needs to be retracted until PyQt5 is ported to newer Python C API
I'm not particularly impressed by the arguments from cculianu. This was the right change to make: this is very general machinery, and we've seen many real issues over the years resulting from implicit acceptance of floats or Decimal objects where an integer is expected.
It may well be that for some *specific* libraries like PyQt5 it makes sense to make a different choice. And indeed, PySide6 has done exactly that:
Python 3.10.0 (default, Nov 12 2021, 12:32:57) [Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PySide6.QtCore import QPoint
>>> QPoint(2, 3)
PySide6.QtCore.QPoint(2, 3)
>>> QPoint(2.1, 3.3)
PySide6.QtCore.QPoint(2, 3)
So no, I don't believe this change should be reverted. At best, we could re-introduce the deprecation warnings and delay the full implementation of the change. But the deprecation warnings were present since Python 3.8, and so either the PyQt5 developers noticed them but didn't want to make the change, or didn't notice them. Either way, it's difficult to see what difference extending the deprecation warning period would make. Moreover, the new behaviour is already released, in Python 3.10.0 and 3.10.1, and the code churn would likely be more annoying than helpful.
I would suggest to cculianu that they take this up with the PyQt5 developers.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36048>
_______________________________________
More information about the Python-bugs-list
mailing list