summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubosz Sarnecki <lubosz@gmail.com>2014-03-23 10:34:10 +0100
committerThibault Saunier <tsaunier@gnome.org>2014-04-01 09:56:13 +0200
commit16979ed48bd0dce9fa1e3711b6bf30b3e65b45ce (patch)
treef8a2c69979b9343169d795f1e858a45815b2fd0f
parentedd21362f63ddb24d504839382ab86e0ab1563ca (diff)
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
-rw-r--r--gi/overrides/Gst.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/gi/overrides/Gst.py b/gi/overrides/Gst.py
index 48c29f9..140b557 100644
--- a/gi/overrides/Gst.py
+++ b/gi/overrides/Gst.py
@@ -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)