[Zope-Checkins] CVS: Zope/lib/python/OFS - Image.py:1.141.4.2

Martijn Pieters mj@zope.com
Wed, 13 Nov 2002 14:18:42 -0500


Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv24278/lib/python/OFS

Modified Files:
      Tag: Zope-2_6-branch
	Image.py 
Log Message:
Backport of fix for #671; pdata chains have remaining size at the start, not
the end.


=== Zope/lib/python/OFS/Image.py 1.141.4.1 => 1.141.4.2 ===
--- Zope/lib/python/OFS/Image.py:1.141.4.1	Fri Oct  4 15:52:51 2002
+++ Zope/lib/python/OFS/Image.py	Wed Nov 13 14:18:41 2002
@@ -323,7 +323,13 @@
                             # calculations allow us to fast-forward through the
                             # Pdata chain without a lot of dereferencing if we
                             # did the work already.
-                            closest_pos = start - (start % (1<<16))
+                            first_size = len(pdata_map[0].data)
+                            if start < first_size:
+                                closest_pos = 0
+                            else:
+                                closest_pos = (
+                                    ((start - first_size) >> 16 << 16) +
+                                    first_size)
                             pos = min(closest_pos, max(pdata_map.keys()))
                             data = pdata_map[pos]