Eric,
That appears to be a bug in older versions of Python;
your test script works as intended in python 2.0 on an
x86 machine of mine, but fails in python 1.5.2 on my
SPARCstation 5. The exception happens in the
numeric-to-string conversion in the print statement:
[bob@mercury py]$ python
Python 1.5.2 (#1, Sep 17 1999, 20:16:17) [GCC egcs-2.91.66 19990314/Linux (egcs-
on linux-sparc
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import string
>>> snum = "0xfffff000"
>>> snum
'0xfffff000'
>>> fnum = string.atol(snum,0)
>>> fnum
4294963200L
>>> pnum = "0x%x" % fnum
Traceback (innermost last):
File "<stdin>", line 1, in ?
OverflowError: long int too long to convert
>>>
whereas
bob@susie:~ > python
Python 2.0 (#1, Jan 19 2001, 17:54:27)
[GCC 2.95.2 19991024 (release)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import string
>>> snum = "0xfffff000"
>>> snum
'0xfffff000'
>>> fnum = string.atol(snum,0)
>>> fnum
4294963200L
>>> pnum = "0x%x" % fnum
>>> pnum
'0xfffff000'
>>> print pnum
0xfffff000
>>> print "0x%x" % string.atol("0xfffff000", 0)
0xfffff000
>>>
I found reference to this problem at
http://mail.python.org/pipermail/python-list/2000-January/019913.html
I'll research this a bit more if you like... perhaps
there's a patch or a straightforward workaround (other
than the obvious "upgrade to Python 2.x").
But, I suppose, you can at least take comfort in the fact
that it's not a user headspace error...
--Bob
On Sat, Jun 02, 2001 at 07:29:40PM -0600, Eric W. Biederman wrote:
> Bob Drzyzgula <[EMAIL PROTECTED]> writes:
>
> > Eric,
> >
> > You mean, like this:
> >
> > bob@susie:~ > echo 'print "0x%x" % 0xfffff000' | python
> > 0xfffff000
>
> The minimal test case is:
> #!/usr/bin/python
> import string
> print "0x%x" % string.atol("0xfffff000", 0)
>
> Here it fails with:
> OverflowError: long int too long to convert
>
> Eric