mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-05 09:00:54 +00:00
python3: apply pep 238 for division overload
Python 3 needs an __truediv__ operator method, used in GstFraction. see: http://legacy.python.org/dev/peps/pep-0238/ https://bugzilla.gnome.org/show_bug.cgi?id=726920
This commit is contained in:
parent
edd21362f6
commit
16979ed48b
1 changed files with 6 additions and 2 deletions
|
@ -243,7 +243,7 @@ class Fraction(Gst.Fraction):
|
|||
|
||||
__rmul__ = __mul__
|
||||
|
||||
def __div__(self, other):
|
||||
def __truediv__(self, other):
|
||||
if isinstance(other, Fraction):
|
||||
return Fraction(self.num * other.denom,
|
||||
self.denom * other.num)
|
||||
|
@ -251,11 +251,15 @@ class Fraction(Gst.Fraction):
|
|||
return Fraction(self.num, self.denom * other)
|
||||
return TypeError
|
||||
|
||||
def __rdiv__(self, other):
|
||||
__div__ = __truediv__
|
||||
|
||||
def __rtruediv__(self, other):
|
||||
if isinstance(other, int):
|
||||
return Fraction(self.denom * other, self.num)
|
||||
return TypeError
|
||||
|
||||
__rdiv__ = __rtruediv__
|
||||
|
||||
def __float__(self):
|
||||
return float(self.num) / float(self.denom)
|
||||
|
||||
|
|
Loading…
Reference in a new issue