summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2015-01-27 16:36:02 +0100
committerChristoph Reiter <creiter@src.gnome.org>2015-03-03 13:19:47 +0100
commit9285b23cd1b253baaf06ddd49e2f000716bbf7f3 (patch)
tree737680a60b16153f3c517d5f03fda46fef7246cd
parentf74acb38f1410982f3419acb134adf173600e497 (diff)
downloadpygobject-9285b23cd1b253baaf06ddd49e2f000716bbf7f3.tar.gz
Add GLib.MINFLOAT etc. and mark GObject.G_MINFLOAT etc. deprecated.
They are defined in glib, not gobject and not included in the gir; Similar constants like G_MAXINT64 are defined in GLib gir and marked deprecated in the GObject overrides already. https://bugzilla.gnome.org/show_bug.cgi?id=743514
-rw-r--r--gi/overrides/GLib.py12
-rw-r--r--gi/overrides/GObject.py4
-rw-r--r--tests/test_overrides_glib.py7
3 files changed, 22 insertions, 1 deletions
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index c1f1691a..455ea842 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -40,6 +40,7 @@ __all__.append('option')
# Types and functions still needed from static bindings
from gi._gi import _glib
+from gi._gi import _gobject
from gi._error import GError
Error = GError
@@ -530,6 +531,17 @@ for n in ['UNKNOWN_OPTION', 'BAD_VALUE', 'FAILED']:
__all__.append(attr)
+# these are not currently exported in GLib gir, presumably because they are
+# platform dependent; so get them from our static bindings
+for name in ['G_MINFLOAT', 'G_MAXFLOAT', 'G_MINDOUBLE', 'G_MAXDOUBLE',
+ 'G_MINSHORT', 'G_MAXSHORT', 'G_MAXUSHORT', 'G_MININT', 'G_MAXINT',
+ 'G_MAXUINT', 'G_MINLONG', 'G_MAXLONG', 'G_MAXULONG', 'G_MAXSIZE',
+ 'G_MINSSIZE', 'G_MAXSSIZE', 'G_MINOFFSET', 'G_MAXOFFSET']:
+ attr = name.split("_", 1)[-1]
+ globals()[attr] = getattr(_gobject, name)
+ __all__.append(attr)
+
+
class MainLoop(GLib.MainLoop):
# Backwards compatible constructor API
def __new__(cls, context=None):
diff --git a/gi/overrides/GObject.py b/gi/overrides/GObject.py
index d0d52252..28408b2f 100644
--- a/gi/overrides/GObject.py
+++ b/gi/overrides/GObject.py
@@ -100,7 +100,9 @@ for name in ['G_MINFLOAT', 'G_MAXFLOAT', 'G_MINDOUBLE', 'G_MAXDOUBLE',
'G_MINSHORT', 'G_MAXSHORT', 'G_MAXUSHORT', 'G_MININT', 'G_MAXINT',
'G_MAXUINT', 'G_MINLONG', 'G_MAXLONG', 'G_MAXULONG', 'G_MAXSIZE',
'G_MINSSIZE', 'G_MAXSSIZE', 'G_MINOFFSET', 'G_MAXOFFSET']:
- globals()[name] = getattr(_gobject, name)
+ new_name = name.split("_", 1)[-1]
+ globals()[name] = getattr(GLib, new_name)
+ deprecated_attr("GObject", name, "GLib." + new_name)
__all__.append(name)
diff --git a/tests/test_overrides_glib.py b/tests/test_overrides_glib.py
index af688952..4f630dc4 100644
--- a/tests/test_overrides_glib.py
+++ b/tests/test_overrides_glib.py
@@ -494,3 +494,10 @@ class TestGVariant(unittest.TestCase):
# with override constructor
v = GLib.Variant('(is)', (1, 'somestring'))
self.assertEqual(str(v), "(1, 'somestring')")
+
+
+class TestConstants(unittest.TestCase):
+
+ def test_basic_types_limits(self):
+ self.assertTrue(isinstance(GLib.MINFLOAT, float))
+ self.assertTrue(isinstance(GLib.MAXLONG, (int, _long)))