mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44:31 +03:00
Make numerator/denominator read only
This commit is contained in:
parent
722ee8240b
commit
79608bd762
|
@ -237,7 +237,7 @@ class IFDRational(Rational):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ('numerator', 'denominator', '_val')
|
__slots__ = ('_numerator', '_denominator', '_val')
|
||||||
|
|
||||||
def __init__(self, value, denominator=1):
|
def __init__(self, value, denominator=1):
|
||||||
"""
|
"""
|
||||||
|
@ -245,18 +245,18 @@ class IFDRational(Rational):
|
||||||
float/rational/other number, or an IFDRational
|
float/rational/other number, or an IFDRational
|
||||||
:param denominator: Optional integer denominator
|
:param denominator: Optional integer denominator
|
||||||
"""
|
"""
|
||||||
self.denominator = denominator
|
self._denominator = denominator
|
||||||
self.numerator = value
|
self._numerator = value
|
||||||
self._val = float(1)
|
self._val = float(1)
|
||||||
|
|
||||||
if type(value) == Fraction:
|
if type(value) == Fraction:
|
||||||
self.numerator = value.numerator
|
self._numerator = value.numerator
|
||||||
self.denominator = value.denominator
|
self._denominator = value.denominator
|
||||||
self._val = value
|
self._val = value
|
||||||
|
|
||||||
if type(value) == IFDRational:
|
if type(value) == IFDRational:
|
||||||
self.denominator = value.denominator
|
self._denominator = value.denominator
|
||||||
self.numerator = value.numerator
|
self._numerator = value.numerator
|
||||||
self._val = value._val
|
self._val = value._val
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -274,6 +274,14 @@ class IFDRational(Rational):
|
||||||
else:
|
else:
|
||||||
self._val = Fraction(value, denominator)
|
self._val = Fraction(value, denominator)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def numerator(a):
|
||||||
|
return a._numerator
|
||||||
|
|
||||||
|
@property
|
||||||
|
def denominator(a):
|
||||||
|
return a._denominator
|
||||||
|
|
||||||
|
|
||||||
def limit_rational(self, max_denominator):
|
def limit_rational(self, max_denominator):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user