[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Lib xmlrpclib.py,1.11,1.12

Skip Montanaro skip@pobox.com (Skip Montanaro)
Wed, 10 Oct 2001 14:09:41 -0500


    SM> xmlrpclib.py
    SM> Log Message: allow long ints to be marshalled as ints - no check
    SM> is made to the incoming value, so the programmer will have to
    SM> catch OverflowError.

    Jeremy> How does the other end unmarshal it?  You shouldn't get overflow
    Jeremy> errors any more.

    Jeremy> Oh, well, actually you do still get overflow and value errors
    Jeremy> from the builtin int().

The receiving end will unmarshal the object into an int.  This is no worse
than the way xmlrpclib treats tuples.  XML-RPC only has an <array> type,
which both lists and tuples marshal into.  On the receiving end <array>
values are always unmarshalled into lists.

    Jeremy> I wonder if there should be a generic number-from-string
    Jeremy> conversion function that returns either a long or an int as
    Jeremy> needed.  If an integer literal in your program text can produce
    Jeremy> a long, why can't builtin int()?

Not sure what you're getting at here. You do have to pass in something that
smells like an int.  "123" would obviously smell like a string and get
marshalled as such.  The XML-RPC spec also indicates that the <int> tag is
restricted to the value that can be represented by a four-byte signed
integer.  It has no type that would marshal a Python long or a native int
that is larger than sys.maxint.  Adding that would be difficult to get past
Dave Winer on the grounds of interoperability.

Skip