From 063562c9860231342b819c69738a0a8d9dffbc4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 22 Feb 2018 10:58:48 +0100 Subject: [PATCH] Allow Bitmask to be created from ints and longs but always store as long We need a 64 bit integer, and previously the test failed because it was already created from longs in various cases (e.g. when reading from a GstStructure). --- gi/overrides/Gst.py | 6 +++--- testsuite/test_types.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gi/overrides/Gst.py b/gi/overrides/Gst.py index a3fc9d1..976bbf1 100644 --- a/gi/overrides/Gst.py +++ b/gi/overrides/Gst.py @@ -443,10 +443,10 @@ class Int64Range(Gst.Int64Range): class Bitmask(Gst.Bitmask): def __init__(self, v): - if not isinstance(v, int): - raise TypeError("%s is not an int." % (type(v))) + if not isinstance(v, long) and not isinstance(v, int): + raise TypeError("%s is not an int or long." % (type(v))) - self.v = v + self.v = long(v) def __str__(self): return hex(self.v) diff --git a/testsuite/test_types.py b/testsuite/test_types.py index 2a87cb9..5e2241f 100644 --- a/testsuite/test_types.py +++ b/testsuite/test_types.py @@ -396,4 +396,4 @@ class TestBitmask(TestCase): Gst.init(None) r = Gst.Bitmask(1 << 5) - self.assertEqual(str(r), '0x20') + self.assertEqual(str(r), '0x20L') -- GitLab