diff --git a/PIL/EpsImagePlugin.py b/PIL/EpsImagePlugin.py index bf0d2cabe..94f3e27f4 100644 --- a/PIL/EpsImagePlugin.py +++ b/PIL/EpsImagePlugin.py @@ -93,7 +93,7 @@ def Ghostscript(tile, size, fp, scale=1): ] if gs_windows_binary is not None: - if gs_windows_binary is False: + if not gs_windows_binary: raise WindowsError('Unable to locate Ghostscript on paths') command[0] = gs_windows_binary diff --git a/PIL/OleFileIO.py b/PIL/OleFileIO.py index b7c984169..2367841e0 100644 --- a/PIL/OleFileIO.py +++ b/PIL/OleFileIO.py @@ -248,7 +248,7 @@ class OleFileIO: if entry[1:2] == "Image": fin = ole.openstream(entry) fout = open(entry[0:1], "wb") - while 1: + while True: s = fin.read(8192) if not s: break diff --git a/PIL/SpiderImagePlugin.py b/PIL/SpiderImagePlugin.py index 9e814932d..cd97c524d 100644 --- a/PIL/SpiderImagePlugin.py +++ b/PIL/SpiderImagePlugin.py @@ -182,7 +182,7 @@ class SpiderImageFile(ImageFile.ImageFile): # given a list of filenames, return a list of images def loadImageSeries(filelist=None): " create a list of Image.images for use in montage " - if filelist == None or len(filelist) < 1: + if filelist is None or len(filelist) < 1: return imglist = [] diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index 3c62fd2dd..68a77e9ca 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -1141,7 +1141,7 @@ def _save(im, fp, filename): # print (im.mode, compression, a, im.encoderconfig) e = Image._getencoder(im.mode, 'libtiff', a, im.encoderconfig) e.setimage(im.im, (0,0)+im.size) - while 1: + while True: l, s, d = e.encode(16*1024) # undone, change to self.decodermaxblock if not _fp: fp.write(d) diff --git a/Tests/cms_test.py b/Tests/cms_test.py index 634e3f717..464c9c7ef 100644 --- a/Tests/cms_test.py +++ b/Tests/cms_test.py @@ -47,7 +47,7 @@ TEST_misc = False ####################################################################### def outputImage(im, funcName = None): # save or display the image, depending on value of SHOW_IMAGES - if SHOW == True: + if SHOW: im.show() else: im.save(os.path.join(OUTPUTDIR, "%s.tif" %funcName)) @@ -57,7 +57,7 @@ def outputImage(im, funcName = None): # The tests themselves ####################################################################### -if TEST_error_catching == True: +if TEST_error_catching: im = Image.open(IMAGE) try: #neither of these proifles exists (unless you make them), so we should @@ -70,7 +70,7 @@ if TEST_error_catching == True: print("error catching test completed successfully (if you see the message \ above that we caught the error).") -if TEST_profileToProfile == True: +if TEST_profileToProfile: # open the image file using the standard PIL function Image.open() im = Image.open(IMAGE) @@ -84,7 +84,7 @@ if TEST_profileToProfile == True: print("profileToProfile test completed successfully.") -if TEST_profileToProfile_inPlace == True: +if TEST_profileToProfile_inPlace: # we'll do the same test as profileToProfile, but modify im in place # instead of getting a new image returned to us im = Image.open(IMAGE) @@ -94,7 +94,7 @@ if TEST_profileToProfile_inPlace == True: outputMode = OUTMODE, inPlace = True) # now that the image is converted, save or display it - if result == None: + if result is None: # this is the normal result when modifying in-place outputImage(im, "profileToProfile_inPlace") else: @@ -103,7 +103,7 @@ if TEST_profileToProfile_inPlace == True: print("profileToProfile in-place test completed successfully.") -if TEST_buildTransform == True: +if TEST_buildTransform: # make a transform using the input and output profile path strings transform = ImageCms.buildTransform(INPUT_PROFILE, OUTPUT_PROFILE, INMODE, \ OUTMODE) @@ -126,7 +126,7 @@ if TEST_buildTransform == True: # Python should also do this automatically when it goes out of scope. del(transform) -if TEST_buildTransformFromOpenProfiles == True: +if TEST_buildTransformFromOpenProfiles: # we'll actually test a couple profile open/creation functions here too # first, get a handle to an input profile, in this case we'll create @@ -160,7 +160,7 @@ if TEST_buildTransformFromOpenProfiles == True: del(outputProfile) del(transform) -if TEST_buildProofTransform == True: +if TEST_buildProofTransform: # make a transform using the input and output and proof profile path # strings # images converted with this transform will simulate the appearance @@ -188,7 +188,7 @@ if TEST_buildProofTransform == True: # Python should also do this automatically when it goes out of scope. del(transform) -if TEST_getProfileInfo == True: +if TEST_getProfileInfo: # get a profile handle profile = ImageCms.getOpenProfile(INPUT_PROFILE) @@ -212,7 +212,7 @@ if TEST_getProfileInfo == True: print("getProfileInfo test completed successfully.") -if TEST_misc == True: +if TEST_misc: # test the versions, about, and copyright functions print("Versions: %s" %str(ImageCms.versions())) print("About:\n\n%s" %ImageCms.about()) diff --git a/Tests/test_file_eps.py b/Tests/test_file_eps.py index e9d051b11..61faa637a 100644 --- a/Tests/test_file_eps.py +++ b/Tests/test_file_eps.py @@ -4,10 +4,10 @@ from PIL import Image, EpsImagePlugin import sys import io -if EpsImagePlugin.gs_windows_binary == False: - # already checked. Not there. +if not EpsImagePlugin.gs_windows_binary: + # already checked. Not there. skip() - + if not sys.platform.startswith('win'): import subprocess try: diff --git a/Tests/threaded_save.py b/Tests/threaded_save.py index 8162e713c..471e24815 100644 --- a/Tests/threaded_save.py +++ b/Tests/threaded_save.py @@ -18,7 +18,7 @@ result = [] class Worker(threading.Thread): def run(self): - while 1: + while True: im = queue.get() if im is None: queue.task_done()