homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Issues with getargs_n() and PyNumber_Index.
Type: Stage:
Components: Interpreter Core Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: trent Nosy List: benjamin.peterson, loewis, trent
Priority: normal Keywords: 64bit, patch

Created on 2008年03月20日 22:00 by trent, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
getargs_and_abstract.patch trent, 2008年03月20日 22:09
Messages (7)
msg64212 - (view) Author: Trent Nelson (trent) * (Python committer) Date: 2008年03月20日 22:00
test_getargs2 fails on Win x64:
test_getargs2 is failing on Windows x64:
test test_getargs2 failed -- Traceback (most recent call last):
 File
"S:\buildbots\python.x643円.0.nelson-win64\build\lib\test\test_getargs2.py",
line 190, in test_n
 self.failUnlessEqual(99, getargs_n(Long()))
TypeError: 'Long' object cannot be interpreted as an integer
The problem is twofold: case 'n' on Win x64 (where SIZEOF_SIZE_T !=
SIZEOF_LONG) had a broken code path and needed updating. Also, the
fallback to 'l' for systems where SIZEOF_SIZE_T == SIZEOF_LONG wasn't
correct -- it should still do a PyNumber_Index() check, and then use
PyLong_AsSize_t() to extract the value.
The attached patch corrects the behaviour on 32-bit and 64-bit systems,
including Windows. However, it has now uncovered another bug in Windows
x64:
>>> from _testcapi import getargs_n
>>> getargs_n(sys.maxsize)
9223372036854775807
>>> getargs_n(-sys.maxsize)
1
>>> getargs_n(-sys.maxsize-1)
0
After a bit of investigation with Martin, the logic in PyLong_AsSize_t()
is incorrect and needs to be reworked to handle negative maximums properly.
msg64214 - (view) Author: Trent Nelson (trent) * (Python committer) Date: 2008年03月20日 22:09
Attach a slightly cleaner patch, take 2.
msg65295 - (view) Author: Trent Nelson (trent) * (Python committer) Date: 2008年04月10日 16:27
Committed patch in r62269. I'll raise a separate tracker issue for 
PyLong_AsSsize_t as it isn't related to this issue.
msg65325 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008年04月10日 21:36
Trent, that commit broke several tests (test_builtin for one) that
relied on a floats not being interpreted as longs.
msg65326 - (view) Author: Trent Nelson (trent) * (Python committer) Date: 2008年04月10日 22:06
Eek, so it does, thanks. Applied the following patch on a bunch of 32-
bit/x64 systems, testing now, so far everything looks good...
Index: abstract.c
===================================================================
--- abstract.c (revision 62279)
+++ abstract.c (working copy)
@@ -1240,7 +1240,7 @@
 return NULL;
 }
 }
- else if (m && m->nb_int != NULL) {
+ else if (m && m->nb_int != NULL && m->nb_float == NULL) {
 result = m->nb_int(item);
 if (result && !PyLong_Check(result)) {
 PyErr_Format(PyExc_TypeError,
msg65327 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008年04月10日 22:30
Thanks for fixing that.
msg65678 - (view) Author: Trent Nelson (trent) * (Python committer) Date: 2008年04月22日 19:03
Update: the changes committed on r62269 and r62279 were incorrect and 
reverted in r62292.
Log:
Issue 2440: revert r62269 and r62279. These changes were made in an 
effort to fix test_args2.Signed_TestCase.test_n(), which was failing on 
Windows x64 on the following line: 'self.failUnlessEqual(99, getargs_n
(Long()))'. Although the two commits *did* fix the test on Windows 
x64, it's become clear that it's the test that's incorrect, and the 
changes to PyNumber_Index() in particular were not warranted (and 
actually violate PEP 357). This commit will get us back to where we 
were at r62268, before I started butchering things.
The reworked patch fixes test_getargs2.py, such that it verifies Long() 
and Int() can't be used as indexes. It also fixes the handling of 'n' 
in getargs.c's convertsimple(). Committed in r62462.
History
Date User Action Args
2022年04月11日 14:56:32adminsetgithub: 46692
2008年04月22日 19:03:23trentsetkeywords: patch, patch, 64bit
messages: + msg65678
2008年04月10日 22:30:29benjamin.petersonsetkeywords: patch, patch, 64bit
messages: + msg65327
2008年04月10日 22:06:36trentsetkeywords: patch, patch, 64bit
messages: + msg65326
2008年04月10日 21:36:40benjamin.petersonsetkeywords: patch, patch, 64bit
nosy: + benjamin.peterson
messages: + msg65325
2008年04月10日 16:27:41trentsetstatus: open -> closed
title: Issues with getargs_n(), PyNumber_Index and PyLong_AsSize_t. -> Issues with getargs_n() and PyNumber_Index.
messages: + msg65295
assignee: trent
keywords: + 64bit
resolution: fixed
2008年03月20日 22:09:16trentsetkeywords: patch, patch
files: + getargs_and_abstract.patch
messages: + msg64214
2008年03月20日 22:07:56trentsetfiles: - getargs_and_abstract.patch
2008年03月20日 22:07:50trentsetmessages: - msg64213
2008年03月20日 22:07:11trentsetkeywords: patch, patch
files: + getargs_and_abstract.patch
messages: + msg64213
2008年03月20日 22:01:42trentsetfiles: - getargs_and_abstract.patch
2008年03月20日 22:00:42trentcreate

AltStyle によって変換されたページ (->オリジナル) /