Merge pull request #2998 from hugovk/simplify-version-checks

Simplify version checks
This commit is contained in:
wiredfool 2018-03-21 07:50:51 +00:00 committed by GitHub
commit c004b6beaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 7 additions and 7 deletions

View File

@ -265,7 +265,7 @@ class PillowLeakTestCase(PillowTestCase):
# helpers
py3 = (sys.version_info >= (3, 0))
py3 = sys.version_info.major >= 3
def fromstring(data):

View File

@ -379,7 +379,7 @@ def _save(im, fp, filename, eps=1):
base_fp = fp
if fp != sys.stdout:
fp = NoCloseStream(fp)
if sys.version_info[0] > 2:
if sys.version_info.major > 2:
fp = io.TextIOWrapper(fp, encoding='latin-1')
if eps:

View File

@ -584,7 +584,7 @@ class Image(object):
# object is gone.
self.im = deferred_error(ValueError("Operation on closed image"))
if sys.version_info >= (3, 4, 0):
if sys.version_info.major >= 3:
def __del__(self):
if (hasattr(self, 'fp') and hasattr(self, '_exclusive_fp')
and self.fp and self._exclusive_fp):

View File

@ -18,7 +18,7 @@ from PIL import Image
import os
import sys
if sys.version_info >= (3, 3):
if sys.version_info.major >= 3:
from shlex import quote
else:
from pipes import quote

View File

@ -27,7 +27,7 @@
import sys
if sys.version_info[0] > 2:
if sys.version_info.major > 2:
import tkinter
else:
import Tkinter as tkinter

View File

@ -653,7 +653,7 @@ class ImageFileDirectory_v2(collections.MutableMapping):
@_register_writer(2)
def write_string(self, value):
# remerge of https://github.com/python-pillow/Pillow/pull/1416
if sys.version_info[0] == 2:
if sys.version_info.major == 2:
value = value.decode('ascii', 'replace')
return b"" + value.encode('ascii', 'replace') + b"\0"

View File

@ -2,7 +2,7 @@
"""
import sys
if sys.version_info[0] > 2:
if sys.version_info.major > 2:
from tkinter import _tkinter as tk
else:
from Tkinter import tkinter as tk