Use named version attributes and simplify version checks

This commit is contained in:
Hugo 2018-02-06 18:39:28 +02:00
parent aef98ef102
commit 13767f045f
6 changed files with 6 additions and 6 deletions

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