[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/file/ fixed handling of unknown data, got an UnboundLocalError: local variable 'w' referenced before assignment

Bernd Dorn bernd.dorn at fhv.at
Thu Aug 17 16:30:57 EDT 2006


Log message for revision 69624:
  fixed handling of unknown data, got an UnboundLocalError: local variable 'w' referenced before assignment

Changed:
  U   Zope3/trunk/src/zope/app/file/image.py
  U   Zope3/trunk/src/zope/app/file/tests/test_image.py

-=-
Modified: Zope3/trunk/src/zope/app/file/image.py
===================================================================
--- Zope3/trunk/src/zope/app/file/image.py	2006-08-17 20:12:42 UTC (rev 69623)
+++ Zope3/trunk/src/zope/app/file/image.py	2006-08-17 20:30:57 UTC (rev 69624)
@@ -133,6 +133,8 @@
         jpeg.read(2)
         b = jpeg.read(1)
         try:
+            w = -1
+            h = -1
             while (b and ord(b) != 0xDA):
                 while (ord(b) != 0xFF): b = jpeg.read(1)
                 while (ord(b) == 0xFF): b = jpeg.read(1)
@@ -150,4 +152,5 @@
         except ValueError:
             pass
 
+
     return content_type, width, height

Modified: Zope3/trunk/src/zope/app/file/tests/test_image.py
===================================================================
--- Zope3/trunk/src/zope/app/file/tests/test_image.py	2006-08-17 20:12:42 UTC (rev 69623)
+++ Zope3/trunk/src/zope/app/file/tests/test_image.py	2006-08-17 20:30:57 UTC (rev 69624)
@@ -156,6 +156,10 @@
         self.assertEqual(s.sizeForDisplay().mapping['width'], '?')
         self.assertEqual(s.sizeForDisplay().mapping['height'], '?')
 
+    def test_getImageInfo(self):
+        from zope.app.file.image import getImageInfo
+        t, w, h = getImageInfo("\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00\xff\xdb\x00C")
+
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(TestImage),



More information about the Zope3-Checkins mailing list