mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 07:57:27 +03:00 
			
		
		
		
	Python3 fixes
This commit is contained in:
		
							parent
							
								
									0bded743f5
								
							
						
					
					
						commit
						a91283061e
					
				|  | @ -46,6 +46,7 @@ __version__ = "1.3.5" | |||
| from PIL import Image, ImageFile | ||||
| from PIL import ImagePalette | ||||
| from PIL import _binary | ||||
| from PIL._util import isStringType | ||||
| 
 | ||||
| import warnings | ||||
| import array, sys | ||||
|  | @ -53,6 +54,8 @@ import collections | |||
| import itertools | ||||
| import os | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| II = b"II" # little-endian (intel-style) | ||||
| MM = b"MM" # big-endian (motorola-style) | ||||
| 
 | ||||
|  | @ -494,7 +497,7 @@ class ImageFileDirectory(collections.MutableMapping): | |||
|             elif typ == 7: | ||||
|                 # untyped data | ||||
|                 data = value = b"".join(value) | ||||
|             elif type(value[0]) in  (str, unicode): | ||||
|             elif isStringType(value[0]): | ||||
|                 # string data | ||||
|                 if isinstance(value, tuple): | ||||
|                     value = value[-1] | ||||
|  | @ -984,7 +987,8 @@ def _save(im, fp, filename): | |||
|     info = im.encoderinfo.get("tiffinfo",{}) | ||||
|     if Image.DEBUG: | ||||
|         print ("Tiffinfo Keys: %s"% info.keys) | ||||
|     for key in info.keys(): | ||||
|     keys = list(info.keys()) | ||||
|     for key in keys: | ||||
|         ifd[key] = info.get(key) | ||||
|         try: | ||||
|             ifd.tagtype[key] = info.tagtype[key] | ||||
|  | @ -1093,14 +1097,11 @@ def _save(im, fp, filename): | |||
|                         # int or similar | ||||
|                         atts[k] = v[0] | ||||
|                         continue | ||||
|                     if type(v) == str: | ||||
|                         atts[k] = v | ||||
|                         continue | ||||
|                     if type(v) == unicode: | ||||
|                     if isStringType(v): | ||||
|                         atts[k] = v.encode('ascii', errors='ignore') | ||||
|                         continue | ||||
| 
 | ||||
|         except Exception, msg: | ||||
|         except (Exception, msg): | ||||
|             # if we don't have an ifd here, just punt. | ||||
|             if Image.DEBUG: | ||||
|                 print (msg) | ||||
|  |  | |||
|  | @ -35,7 +35,7 @@ def test_read_metadata(): | |||
|              'ImageLength': (128,), | ||||
|              'Compression': (4,), | ||||
|              'FillOrder': (1,), | ||||
|              'DocumentName': u'lena.g4.tif', | ||||
|              'DocumentName': 'lena.g4.tif', | ||||
|              'RowsPerStrip': (128,), | ||||
|              'ResolutionUnit': (1,), | ||||
|              'PhotometricInterpretation': (0,), | ||||
|  | @ -46,7 +46,7 @@ def test_read_metadata(): | |||
|              'StripByteCounts': (1796,), | ||||
|              'SamplesPerPixel': (1,), | ||||
|              'StripOffsets': (8,), | ||||
|              'Software': u'ImageMagick 6.5.7-8 2012-08-17 Q16 http://www.imagemagick.org'} | ||||
|              'Software': 'ImageMagick 6.5.7-8 2012-08-17 Q16 http://www.imagemagick.org'} | ||||
| 
 | ||||
|     # assert_equal is equivalent, but less helpful in telling what's wrong.  | ||||
|     named = img.tag.named() | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user