mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Use named version attributes and simplify version checks
This commit is contained in:
parent
aef98ef102
commit
13767f045f
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user