Satisfying Pillow's Python 3 deprecation warnings
authorAndy Robinson <andy@reportlab.com>
Thu, 30 May 2013 11:08:55 +0100
changeset 3695 1b0c70ee944f
parent 3694 953a2d87274a
child 3696 d3f1be527d01
Satisfying Pillow's Python 3 deprecation warnings
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
@@ -650,7 +650,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())