[XML-SIG] Ann: xvif 0.2.0

Michael McLay mclay@nist.gov
Tue, 1 Oct 2002 11:40:37 -0400


On Tuesday 01 October 2002 11:14 am, Eric van der Vlist wrote:
> Hi Michael and Fred,
>
> On Tue, 2002-10-01 at 17:06, Fred L. Drake, Jr. wrote:
> > Michael McLay writes:
> >  > The Python long type has been merged with int and if I recall
> >  > corrrectly the use of long has been deprecated. The syntax for int
> >  > literals would also be more compatible with xs:integer than the
> >  > long literals.
> >
> > I'm not sure what you mean by "merged"; they are decidely two distinct
> > types with incompatible internal representations.  This is unlikely to
> > change.  To the best of my knowledge, the long() constructor has not
> > been deprecated.

Sorry, I worded that very poorly. I was refering to the changes you correctly 
described in the paragraph that follows.

> > What has changed is that functions written in C are now much more
> > likely to accept a long if the value is in the range of a C int, and
> > Python will generate a long as needed for literals that exceed the
> > range of an int.

I was suprised to find that the automatic conversion of literals to longs 
doesn't seem to work. Instead the following occur:

Python 2.1.1 (#1, Aug 30 2001, 17:36:05)
>>> a = 453326663432
OverflowError: integer literal too large

The "L" still needs to be there for literals.

>>> a = 453326663432L
>>> a
453326663432L

I thought I read that this "L" was no longer necessary.

> What I can tell is that if I change "long" to "int" as a base class for
> the integer type, the test cases testing large value do fail.
>
> It is the case for instance for this value:
>
> <?xml version="1.0" encoding="utf-8"?>
>       <doc>4294967295</doc>
> which is then considered invalid.
>
> I am running python 2.2.1 on Debian sid:

I should have tested this prior to posting. I thought the conversion to long 
when an int overflow occured was now automatic. Now that I've tested this I 
see that it isn't true. I withdraw my suggestion.

Python 2.1.1 (#1, Aug 30 2001, 17:36:05)
[GCC 2.96 20000731 (Mandrake Linux 8.1 2.96-0.61mdk)] on linux-i386
Type "copyright", "credits" or "license" for more information.
>>> int("2073741824")
2073741824
>>> int("4073741824")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: int() literal too large: 4073741824
>>> long("4073741824")
4073741824L
>>>