Satisfying Pillow's Python 3 deprecation warnings py33
authorAndy Robinson <andy@reportlab.com>
Thu, 30 May 2013 11:08:55 +0100
branchpy33
changeset 3741 0cadc486be4a
parent 3740 9f4b1ba103f7
child 3751 1809185f0a36
Satisfying Pillow's Python 3 deprecation warnings (grafted from 1b0c70ee944f5503ca281a3ecab9be817b5c1ca8)
src/reportlab/__init__.py
src/reportlab/lib/utils.py
--- a/src/reportlab/__init__.py	Tue May 21 11:17:03 2013 +0100
+++ b/src/reportlab/__init__.py	Thu May 30 11:08:55 2013 +0100
@@ -7,8 +7,13 @@
 
 import sys
 
-if sys.version_info[0:2] < (2, 5):
-    warning = """The trunk of reportlab currently requires Python 2.5 or higher.
+if sys.version_info[0:2] < (2, 7):
+    warning = """The trunk of reportlab currently requires Python 2.7 or higher.
+
+    This is being done to let us move forwards with 2.7/3.x compatibility
+    with the minimum of baggage.
+    
+    ReportLab 2.7 was the last packaged version to suppo0rt Python 2.5 and 2.6.
 
     Python 2.3 users may still use ReportLab 2.4 or any other bugfixes
     derived from it, and Python 2.4 users may use ReportLab 2.5.  
--- a/src/reportlab/lib/utils.py	Tue May 21 11:17:03 2013 +0100
+++ b/src/reportlab/lib/utils.py	Thu May 30 11:08:55 2013 +0100
@@ -656,7 +656,10 @@
                     elif mode not in ('L','RGB','CMYK'):
                         im = im.convert('RGB')
                         self.mode = 'RGB'
-                    self._data = im.tostring()
+                    if hasattr(im, 'tobytes'):  #make pillow and PIL both happy, for now
+                        self._data = im.tobytes()
+                    else:
+                        self._data = im.tostring()
             return self._data
         except:
             annotateException('\nidentity=%s'%self.identity())