[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2021-12-09 Thread Calin Culianu
Calin Culianu added the comment: Ok, Guido, thanks. Fair enough. So regardless: what is the problem exactly if a C function expects an int but gets given a float? Why does such strictness matter, in that it required a whole other set of __index__ etc to be added? I am having trouble seeing

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2021-12-09 Thread Guido van Rossum
Guido van Rossum added the comment: Claim, you need to tone down the rhetoric. Python is not C++ and user expectations are different. You are the one who is fighting windmills here. -- ___ Python tracker

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2021-12-09 Thread Calin Culianu
Calin Culianu added the comment: Ok, well I found this in that issue you linked to: This is the original "problem": ``` type __mul__ is wierd: >> 'a'.__mul__(3.4) 'aaa' >>> [1].__mul__(3.4) [1, 1, 1] ``` And this is Guido's response: > The problem is that on the one hand you want "i" to

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2021-12-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: See issue660144 which made float values be rejected in most cases where an integer is expected rather of silently truncating them. It was at 2003. Guido mentioned that is an age-old problem, so perhaps you can find older discussions on the tracker or

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2021-12-09 Thread Calin Culianu
Calin Culianu added the comment: Hi, I'm cculianu, the reporting user. May I get a link or some background for the motivation for this change? It seems to me that there are vague allusions to "Decimal -> int cause problems in past", or some such, and I'd like to read the arguments presented

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2021-12-09 Thread Mark Dickinson
Mark Dickinson added the comment: For the record, #37999 is the issue that turned the deprecation warnings into errors for Python 3.10. (But as Serhiy says, please open a new issue, or start a discussion on one of the mailing lists.) -- ___

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2021-12-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This issue was closed more than 2.5 years ago. The changes were made in 3.8, not in 3.10. BTW, 3.8 only accepts security fixes now. Please open a new issue for new discussion. -- ___ Python tracker

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2021-12-09 Thread Mark Dickinson
Mark Dickinson 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

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2021-12-08 Thread Oleg Iarygin
Oleg Iarygin added the comment: The reporter gave more details (): > Literally this is ok in C++ with Qt: > > float x = 2.3, y = 1.1; > auto p = QPoint(x, y); // QPoint only takes 2 int params.. this works in >

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2021-12-08 Thread Oleg Iarygin
Oleg Iarygin added the comment: Here is a report that this change breaks PyQt5 on Fedora: > [...] > > Why do I care? This breaks tons of existing PyQt5 code out there, for > example. I wasn't aware of this change to the

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2020-01-15 Thread STINNER Victor
STINNER Victor added the comment: > Serhiy: any thoughts about what version should be targeted for eventual > removal of the functionality deprecated in this PR? 3.10? IMHO it should be done at the *very beginning* of a release cycle. Python 3.9.0 alpha 1 *and* alpha 2 versions have already

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2019-12-28 Thread Mark Dickinson
Mark Dickinson added the comment: Serhiy: any thoughts about what version should be targeted for eventual removal of the functionality deprecated in this PR? 3.10? -- ___ Python tracker

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2019-06-03 Thread Mark Dickinson
Change by Mark Dickinson : -- pull_requests: +13659 pull_request: https://github.com/python/cpython/pull/13740 ___ Python tracker ___

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2019-04-27 Thread Miro Hrončok
Miro Hrončok added the comment: Relevant NumPy issue: https://github.com/numpy/numpy/issues/13412 -- nosy: +hroncok ___ Python tracker ___

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2019-02-25 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2019-02-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 6a44f6eef3d0958d2347190b3e2d1222c2e9 by Serhiy Storchaka in branch 'master': bpo-36048: Use __index__() instead of __int__() for implicit conversion if available. (GH-11952)

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2019-02-20 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: > I am not sure what to with the int constructor. Should it try __index__ > before __int__? Or just make __index__ without __int__ setting the nb_int > slot as was proposed by Nick in issue33039? Shouldn't it try only __int__ since this will default to

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2019-02-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I am not sure what to with the int constructor. Should it try __index__ before __int__? Or just make __index__ without __int__ setting the nb_int slot as was proposed by Nick in issue33039? -- ___ Python

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2019-02-20 Thread STINNER Victor
STINNER Victor added the comment: See also bpo-34423: "Overflow when casting from double to time_t, and_PyTime_t" or "How to reduce precision loss when converting arbitrary number to int or float?". -- ___ Python tracker

[issue36048] Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__

2019-02-20 Thread STINNER Victor
Change by STINNER Victor : -- title: Deprecate implicit truncating when convert Python numbers to C integers -> Deprecate implicit truncating when convert Python numbers to C integers: use __index__, not __int__ ___ Python tracker