mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
py3k: Type coercion is gone
Types aren't automatically converted for operations for you.
This commit is contained in:
parent
80c2fa60ae
commit
275a895952
13
PIL/Image.py
13
PIL/Image.py
|
@ -396,11 +396,16 @@ def _getencoder(mode, encoder_name, args, extra=()):
|
|||
# --------------------------------------------------------------------
|
||||
# Simple expression analyzer
|
||||
|
||||
def coerce_e(value):
|
||||
return value if isinstance(value, _E) else _E(value)
|
||||
|
||||
class _E:
|
||||
def __init__(self, data): self.data = data
|
||||
def __coerce__(self, other): return self, _E(other)
|
||||
def __add__(self, other): return _E((self.data, "__add__", other.data))
|
||||
def __mul__(self, other): return _E((self.data, "__mul__", other.data))
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
def __add__(self, other):
|
||||
return _E((self.data, "__add__", coerce_e(other).data))
|
||||
def __mul__(self, other):
|
||||
return _E((self.data, "__mul__", coerce_e(other).data))
|
||||
|
||||
def _getscaleoffset(expr):
|
||||
stub = ["stub"]
|
||||
|
|
Loading…
Reference in New Issue
Block a user