[ZODB-Dev] SVN: persistent/trunk/ Worked around test failure due to overflow to long on 32-bit systems.

Tres Seaver tseaver at palladion.com
Thu Nov 15 17:37:36 UTC 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/15/2012 11:47 AM, Jim Fulton wrote:
> On Sun, Aug 26, 2012 at 2:30 PM, Tres Seaver
> <cvs-admin at zope.org> wrote:
>> Log message for revision 127583:
> 
> ...
> 
>> Modified: persistent/trunk/persistent/cPersistence.c 
>> ===================================================================
> 
> ...
> 
>> @@ -1118,6 +1118,14 @@ { if (v) { +      if (PyLong_Check(v)) +
>> { +          long long llv = PyInt_AsLongLong(v); +          if (llv
>> > sys_maxint) +          { +             v = sys_maxint;  /* borrow
>> reference */ +          } +      }
> 
> This is wrong.  You're comparing a long long and a PyObject*.


Thanks.  The attached patch should fix it to compare the value of the
largest allowed size, rather than its pointer.  Does that look correct?


>> Modified: persistent/trunk/persistent/tests/test_persistence.py 
>> =================================================================== 
>> --- persistent/trunk/persistent/tests/test_persistence.py
>> 2012-08-26 16:19:07 UTC (rev 127582) +++
>> persistent/trunk/persistent/tests/test_persistence.py
>> 2012-08-26 18:30:20 UTC (rev 127583) @@ -504,9 +504,18 @@
>> 
>> def test_assign_p_estimated_size_bigger(self): inst =
>> self._makeOne() -        inst._p_estimated_size = 1073741697 * 1024 
>> +        inst._p_estimated_size = 1073741697 * 4 #still <= 32 bits 
>> self.assertEqual(inst._p_estimated_size, 16777215 * 64)
> 
> This test is meant to test that the code that prevents us from 
> overflowing the 30-bits reserved for storring estimated sizes.  Using 
> * 2 (rather than * 4) should be enough.

OK.  If we are truncating anyway, it shouldn't matter.

> We don't really need to support Python longs, do we?  We just need to 
> fix the test to not provoke a long.
> 
> If someone sets a size >2G on a 32-bit platform, they'll get a type 
> error.  I don't think this is a big problem.  If they're doing this, 
> they probably have other problems. :)

The C code raises ValueError in that case.  I don't care whether we
truncate or not:  if you think that an exception works, I'm fine with
changing the tests (and the Python implementation) to fit.

> I propose to revert this change and change 1024 to 2.



Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlClKGAACgkQ+gerLs4ltQ7xGwCggARtQgeOSrAES6QJplyer+/k
a44AoJQZoEMzyrGoTrAzCf256EkKSOsv
=ogkb
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: persistent-compare.patch
Type: text/x-patch
Size: 1262 bytes
Desc: not available
URL: <http://mail.zope.org/pipermail/zodb-dev/attachments/20121115/77e054ff/attachment.bin>


More information about the ZODB-Dev mailing list