mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44: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
|
base_fp = fp
|
||||||
if fp != sys.stdout:
|
if fp != sys.stdout:
|
||||||
fp = NoCloseStream(fp)
|
fp = NoCloseStream(fp)
|
||||||
if sys.version_info[0] > 2:
|
if sys.version_info.major > 2:
|
||||||
fp = io.TextIOWrapper(fp, encoding='latin-1')
|
fp = io.TextIOWrapper(fp, encoding='latin-1')
|
||||||
|
|
||||||
if eps:
|
if eps:
|
||||||
|
|
|
@ -584,7 +584,7 @@ class Image(object):
|
||||||
# object is gone.
|
# object is gone.
|
||||||
self.im = deferred_error(ValueError("Operation on closed image"))
|
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):
|
def __del__(self):
|
||||||
if (hasattr(self, 'fp') and hasattr(self, '_exclusive_fp')
|
if (hasattr(self, 'fp') and hasattr(self, '_exclusive_fp')
|
||||||
and self.fp and self._exclusive_fp):
|
and self.fp and self._exclusive_fp):
|
||||||
|
|
|
@ -18,7 +18,7 @@ from PIL import Image
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if sys.version_info >= (3, 3):
|
if sys.version_info.major >= 3:
|
||||||
from shlex import quote
|
from shlex import quote
|
||||||
else:
|
else:
|
||||||
from pipes import quote
|
from pipes import quote
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if sys.version_info[0] > 2:
|
if sys.version_info.major > 2:
|
||||||
import tkinter
|
import tkinter
|
||||||
else:
|
else:
|
||||||
import Tkinter as tkinter
|
import Tkinter as tkinter
|
||||||
|
|
|
@ -653,7 +653,7 @@ class ImageFileDirectory_v2(collections.MutableMapping):
|
||||||
@_register_writer(2)
|
@_register_writer(2)
|
||||||
def write_string(self, value):
|
def write_string(self, value):
|
||||||
# remerge of https://github.com/python-pillow/Pillow/pull/1416
|
# 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')
|
value = value.decode('ascii', 'replace')
|
||||||
return b"" + value.encode('ascii', 'replace') + b"\0"
|
return b"" + value.encode('ascii', 'replace') + b"\0"
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if sys.version_info[0] > 2:
|
if sys.version_info.major > 2:
|
||||||
from tkinter import _tkinter as tk
|
from tkinter import _tkinter as tk
|
||||||
else:
|
else:
|
||||||
from Tkinter import tkinter as tk
|
from Tkinter import tkinter as tk
|
||||||
|
|
Loading…
Reference in New Issue
Block a user