Title: bad repr of itertools.count object with negative value on OS X 10.4 with 10.5 build
Type: behavior Stage: needs patch
Components: macOS Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: loewis, ned.deily, rhettinger, ronaldoussoren
Priority: release blocker Keywords:

Created on 2009-04-01 19:30 by ned.deily, last changed 2009-04-19 10:42 by ronaldoussoren. This issue is now closed.

Messages (5)
msg85081 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2009-04-01 19:30
Observed failure of regression test:

FAIL: test_count (test.test_itertools.TestBasicOps)
Traceback (most recent call last):
"/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/test/te", line 215, in test_count
    self.assertEqual(repr(c), 'count(-9)')
AssertionError: 'count(4294967287)' != 'count(-9)'

Problem can be reproduced using the 3.0.1 OS X installer on a 
PPC (G3) system running 10.4:

/Library/Frameworks/Python.framework/Versions/3.0$ bin/python3.0
Python 3.0.1 (r301:69597, Feb 14 2009, 19:03:52) 
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from itertools import count
>>> x = count(-2)
>>> x
>>> next(x)
>>> x
>>> next(x)
>>> x
>>> next(x)
>>> x
nad@pbg3:/Library/Frameworks/Python.framework/Versions/3.0$ uname -a
Darwin 8.11.0 Darwin Kernel Version 8.11.0: Wed Oct 10 
18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC Power Macintosh 

But the same installer on another PPC (G4) system running 10.5 works 

/Library/Frameworks/Python.framework/Versions/3.0$ bin/python3.0
Python 3.0.1 (r301:69597, Feb 14 2009, 19:03:52) 
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from itertools import count
>>> x = count(-2)
>>> x
>>> next(x)
nad@pbg4:/Library/Frameworks/Python.framework/Versions/3.0$ uname -a
Darwin pbg4.local 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:39:01 
PST 2008; root:xnu-1228.9.59~1/RELEASE_PPC Power Macintosh

Further analysis shows that the problem is reproducible on the 10.4 
system with any current build (2.x/3.x) if the installer build is made 
on a 10.5 system with the default deployment target of 10.3; the correct 
results are seen if the image is installed on a 10.5 system.  If the 
same source snapshot is used to build an installer image on the 10.4 
system, the resulting image does not exhibit this bug, either on the 
10.4 or on 10.5 systems.  

More analysis is needed.

It would be helpful if anyone with access to another 10.4 PPC or Intel 
system could try the above code snippet using the 3.0.1 OS X from
msg85140 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-04-02 02:42
Martin, do you have any insight into this?  The values being seen and
the fact that it occurs only in a particular build suggests that
pyport.h has inconsistent definitions for Py_ssize_t, PY_SSIZE_T_MAX,
and PY_SSIZE_T_MIN.  The values look like signed and unsigned values are
being conflated.
msg85191 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-04-02 10:30
Raymond: My guess is that this is caused because the binary was build on 
OSX 10.5, where 'printf("%zd")' works file for negative numbers, and the 
tests was run on OSX 10.4, where the same printf statement doesn't work 

I'll experiment with a fix for this over the weekend. The fix I'm thinking 
of right now is to patch either or pymacconfig.h to make sure 
that PY_FORMAT_SIZE_T is overridden when building a binary that has a 
DEPLOYMENT_TARGET that is smaller than 10.5.
msg86029 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-04-16 13:05
I intend to fix this next weekend, therefore assigning the issue to 
msg86161 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-04-19 10:42
Fixed in r71743 (trunk), r71744 (2.6), r71746 (3.0), r71745 (3.1)
Date User Action Args
2009-04-19 10:42:01ronaldoussorensetstatus: open -> closed
resolution: fixed
messages: + msg86161
2009-04-16 13:05:40ronaldoussorensetpriority: release blocker
messages: + msg86029

assignee: loewis -> ronaldoussoren
type: behavior
stage: needs patch
2009-04-02 10:30:21ronaldoussorensetmessages: + msg85191
2009-04-02 02:42:35rhettingersetassignee: rhettinger -> loewis

messages: + msg85140
nosy: + loewis
2009-04-01 23:09:20georg.brandlsetassignee: rhettinger

nosy: + rhettinger
2009-04-01 19:30:27ned.deilycreate