[Checkins] SVN: persistent/trunk/ Worked around test failure due to overflow to long on 32-bit systems.
Jim Fulton
jim at zope.com
Thu Nov 15 16:47:33 UTC 2012
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*.
...
>
> 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.
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. :)
I propose to revert this change and change 1024 to 2.
Jim
--
Jim Fulton
http://www.linkedin.com/in/jimfulton
Jerky is better than bacon! http://zo.pe/Kqm
More information about the checkins
mailing list