classification
Title: len(str(x)) in decimal.py is not Python 2.3 compatible
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: ncoghlan, rhettinger, tim.peters
Priority: normal Keywords:

Created on 2004-09-29 23:36 by ncoghlan, last changed 2004-09-30 06:09 by ncoghlan. This issue is now closed.

Messages (4)
msg22570 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2004-09-29 23:36
One of the stated goals of decimal.py is to remain 2.3
compatible.

This is not currently the case, as the len(str(x))
trick I used to determine the 'number of digits in an
integer' gives the wrong answer for long integers in
Python 2.3 (there is an extra 'L' on the end).
msg22571 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-09-30 00:34
Logged In: YES 
user_id=80475

Check again.
str(123L) automatically drops the L
repr(123L) keeps it.

I had run the decimal tests on Py2.3 without exception.

So, please reverify your claim.  If valid, show an example
where it doesn't work, add that example as a test case, and
submit a patch.
msg22572 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-09-30 01:04
Logged In: YES 
user_id=31435

Indeed, please give a specific example, and point out exactly 
what in that example you think should change, and how you 
think it should change.  Else I've got no idea what you're 
talking about either.

>>> import decimal
>>> a = decimal.Decimal(3)
>>> str(a)
'3'
>>> len(str(a))
1
>>>

That's under current CVS Python, and I see nothing 
objectionable in it.  I'd bet several pennies it works the same 
under 2.3.4.
msg22573 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2004-09-30 06:09
Logged In: YES 
user_id=1038590

Gah, you're right. Sorry - I was doing something else in Py
2.3, and had the L's showing up. And then I overreacted and
thought I'd made the same mistake in decimal.py, and created
the bug report to make sure I didn't forget to go back and
check.

However, I was using repr() for what I was doing (whereas
decimal.py uses str()). False alarm. Nothing to see here.
Move along. . .
History
Date User Action Args
2004-09-29 23:36:21ncoghlancreate