[ python-Bugs-1037373 ] len(str(x)) in decimal.py is not Python 2.3 compatible

SourceForge.net noreply at sourceforge.net
Thu Sep 30 08:09:10 CEST 2004


Bugs item #1037373, was opened at 2004-09-30 09:36
Message generated for change (Comment added) made by ncoghlan
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1037373&group_id=5470

Category: Python Library
Group: Python 2.4
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Nick Coghlan (ncoghlan)
Assigned to: Raymond Hettinger (rhettinger)
Summary: len(str(x)) in decimal.py is not Python 2.3 compatible

Initial Comment:
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).


----------------------------------------------------------------------

>Comment By: Nick Coghlan (ncoghlan)
Date: 2004-09-30 16:09

Message:
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. . .

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2004-09-30 11:04

Message:
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.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-09-30 10:34

Message:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1037373&group_id=5470


More information about the Python-bugs-list mailing list