A fix for OverflowError in 64bits platforms

  • Thread starter Manuel Vazquez Acosta
  • Start date
M

Manuel Vazquez Acosta

Hi all,

I'm debugging a Plone site in an AMD64 laptop. When I first tried to run
Zope, I got this exception:

OverflowError: signed integer is greater than maximum

In the archives I encounter no solutions. This is what I could find, so
I share with you all:

It seems that on 64bit platforms, sys.maxint is much greater than list's
insertion maximum index. I'm not sure if this a bug in python or a
logical bound ---given the amount of RAM it would take to insert
9,223,372,036,854,775,807 items ;)--- Maybe a bug in the documentation,
though

However, Archetypes.Schema.moveField method documents the use of maxint
for inserting at the end of the Schema::
maxint can be used to move the field to the last position possible ['b', 'c', 'a']

I have seen this usage in some products. This raises and OverflowError
on 64bit platforms.

The fix is simple in the code of the caller::
from sys import maxint
if maxint >> 33: # Am I running on 64bits?
maxint = maxint >> 33
theschema.moveField(the_name, pos=maxint)

Now, the maxint variable holds an acceptable value.

I think the docstring should be appended with a "Note: On 64bits
platform this raises an OverflowError blah blah..."

Best regards,
Manuel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top