[issue4910] Remove uses of nb_long slot, and rename to nb_reserved.
Mark Dickinson dicki...@gmail.com added the comment: PyNumber_Int deprecated in r69517, r69518. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4910 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4910] Remove uses of nb_long slot, and rename to nb_reserved.
Mark Dickinson dicki...@gmail.com added the comment: Thanks again for reviewing, Benjamin. nb_long renamed in r68651, merged to 3.0 (along with a few other long-int cleanups) in r68666. There seems to be a consensus on deprecating PyNumber_Int. I'll leave this open until that's taken care of. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4910 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4910] Remove uses of nb_long slot, and rename to nb_reserved.
Mark Dickinson dicki...@gmail.com added the comment: Here's a patch that deprecates PyNumber_Int in favour of PyNumber_Long: - move PyNumber_Int definition from abstract.h to intobject.h (and fix up comments at the top of intobject.h) - mark PyNumber_Int as deprecated in the c-api docs, with a promise to remove it for 3.1. I suppose that in theory this goes too far: we should really deprecate in 3.1 and remove in 3.2. But given all the other stuff that's going on for 3.0.1, this doesn't seem too bad. Benjamin, what do you think? N.B. We should remember to actually remove intobject.h for 3.1. :) Added file: http://bugs.python.org/file12781/issue4910_4.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4910 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4910] Remove uses of nb_long slot, and rename to nb_reserved.
Benjamin Peterson benja...@python.org added the comment: +1 for applying the last patch. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4910 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4910] Remove uses of nb_long slot, and rename to nb_reserved.
Mark Dickinson dicki...@gmail.com added the comment: Thanks, Benjamin! Checked in in r68553, backported to 3.0 in r68556. Here's the second patch, which fixes almost all remaining uses of nb_long but stops short of actually removing/renaming the nb_long slot. Notes: (1) I haven't tested the change to PC/winreg.c (2) The Modules/_struct.c change does introduce a change in behaviour: for example, before the patch, struct.pack('q', decimal.Decimal(1)) raises struct.error. After the patch, the packing succeeds. I *think* the patched behaviour is probably the right behaviour, since it agrees with 2.x, but it's not 100% clear to me what the intentions of the struct module are with respect to integer packing of non-integer types. This is probably a question for another issue. Added file: http://bugs.python.org/file12754/issue4910_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4910 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4910] Remove uses of nb_long slot, and rename to nb_reserved.
Benjamin Peterson benja...@python.org added the comment: On Thu, Jan 15, 2009 at 10:48 AM, Mark Dickinson rep...@bugs.python.org wrote: Mark Dickinson dicki...@gmail.com added the comment: Thanks, Benjamin! Checked in in r68553, backported to 3.0 in r68556. Here's the second patch, which fixes almost all remaining uses of nb_long but stops short of actually removing/renaming the nb_long slot. Notes: (1) I haven't tested the change to PC/winreg.c This looks correct. In fact, I don't really see the point of having PyHKEY_unaryFailureFunc since a TypeError will automatically be raised if the slot is NULL, but that is certainly another issue. (2) The Modules/_struct.c change does introduce a change in behaviour: for example, before the patch, struct.pack('q', decimal.Decimal(1)) raises struct.error. After the patch, the packing succeeds. I *think* the patched behaviour is probably the right behaviour, since it agrees with 2.x, but it's not 100% clear to me what the intentions of the struct module are with respect to integer packing of non-integer types. This is probably a question for another issue. Since Decimal implements __int__ and that's what the struct module is converting with, I think this is fine. Overall, the patch looks fine. I wonder if we should mark PyNumber_Long as deprecated in the docs, though. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4910 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4910] Remove uses of nb_long slot, and rename to nb_reserved.
Mark Dickinson dicki...@gmail.com added the comment: I wonder if we should mark PyNumber_Long as deprecated in the docs, though. It would be nice to standardize on one of (PyNumber_Long, PyNumber_Int) and document the other as deprecated. Maybe it would make more sense to stick with PyNumber_Long and deprecate PyNumber_Int, though? It would make 2.x - 3.x transitions easier, and would be consistent with some of the rest of the API: we seem to be using PyLong_Check in preference to PyInt_Check in current code... ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4910 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4910] Remove uses of nb_long slot, and rename to nb_reserved.
Mark Dickinson dicki...@gmail.com added the comment: Second patch applied in r68619 (py3k) and r68620 (3.0 maintenance branch). Here's the third and final patch: rename the nb_long slot to nb_reserved, and change its type to (void *). Added file: http://bugs.python.org/file12756/issue4910_3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4910 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4910] Remove uses of nb_long slot, and rename to nb_reserved.
Mark Dickinson dicki...@gmail.com added the comment: Here's a patch against the py3k branch that gets rid of the two existing uses of nb_long in the core: - in PyNumber_Long, conversion was attempted first using nb_int and then using nb_long. The patch simply removes the nb_long code, so int(x) no longer attempts to use the __long__ method for conversion. - in Modules/_struct.c, there's a call to nb_long in a function that's attempting to turn an arbitrary PyObject into a PyLongObject; the patch replaces this with nb_int (and updates an error message). - In Lib/test/test_long.py, __long__ has been replaced with __int__ in a test that __int__/__long__ takes precedence over __trunc__ for conversion to int. With this patch, all tests pass on my (OS X 10.5/Intel) machine. (Except test_socket, but I'm 97.2% certain that's unrelated.) If someone can review this quickly I'll move on to the next patch towards removing nb_long. (My issue #1717 experience suggests that it ought to be easier to effect the removal via a series of 3 or 4 short, easy-to-review patches with clear intent than via one bigger, more confused patch.) I think it would be good if nb_long could be altered before 3.0.1. Benjamin, do you have time to take a look? -- assignee: - benjamin.peterson keywords: +patch nosy: +benjamin.peterson priority: - critical title: Should both nb_long and nb_int still exist in 3.x? - Remove uses of nb_long slot, and rename to nb_reserved. type: - behavior Added file: http://bugs.python.org/file12696/issue4910_1.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4910 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4910] Remove uses of nb_long slot, and rename to nb_reserved.
Mark Dickinson dicki...@gmail.com added the comment: That was a pretty poor patch. Here's a better one: - added Misc/NEWS entry - added tests to check that __long__ is never called - removed Modules/_struct.c change, in the interests of keeping the patch focused. Added file: http://bugs.python.org/file12697/issue4910_1a.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4910 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4910] Remove uses of nb_long slot, and rename to nb_reserved.
Benjamin Peterson benja...@python.org added the comment: The first installment looks good! ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4910 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com