[pygobject] Drop static glib_version and pyglib_version constants
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Drop static glib_version and pyglib_version constants
- Date: Sat, 3 Nov 2012 13:19:37 +0000 (UTC)
commit 8d52bceb1e0aa0dc79cf77f36dda9f953f170459
Author: Martin Pitt <martinpitt gnome org>
Date: Sat Nov 3 13:14:15 2012 +0100
Drop static glib_version and pyglib_version constants
Use the GLib version from GI instead, and the already existing gi.version_info.
docs/reference/pyglib-constants.xml | 50 --------------------------------
docs/reference/pygobject-constants.xml | 19 ------------
gi/_glib/__init__.py | 2 -
gi/_glib/glibmodule.c | 21 -------------
gi/_gobject/__init__.py | 1 -
gi/overrides/GLib.py | 8 ++++-
gi/overrides/GObject.py | 3 +-
tests/test_glib.py | 12 +++++++
8 files changed, 21 insertions(+), 95 deletions(-)
---
diff --git a/docs/reference/pygobject-constants.xml b/docs/reference/pygobject-constants.xml
index 07c3fdd..ed217f7 100644
--- a/docs/reference/pygobject-constants.xml
+++ b/docs/reference/pygobject-constants.xml
@@ -299,25 +299,6 @@ by gobject.</para>
</refsect2>
- <refsect2 id="gobject-version-constants">
- <title id="gobject-version-constants-title">GObject Version Constants</title>
-
- <para>The Version constants specify the version of
-<literal>GLIB</literal> used by PyGTK as a 3-tuple containing the major,
-minor and patch release numbers.</para>
-
- <variablelist>
- <varlistentry>
- <term><literal>gobject.glib_version</literal></term>
- <listitem>
- <simpara>A 3-tuple containing (major, minor, patch) release
- numbers.</simpara>
- </listitem>
- </varlistentry>
- </variablelist>
-
- </refsect2>
-
</refsect1>
</refentry>
diff --git a/gi/_glib/__init__.py b/gi/_glib/__init__.py
index 236aaaf..9faefb6 100644
--- a/gi/_glib/__init__.py
+++ b/gi/_glib/__init__.py
@@ -46,7 +46,5 @@ OPTION_REMAINING = _glib.OPTION_REMAINING
# Functions
filename_from_utf8 = _glib.filename_from_utf8
-glib_version = _glib.glib_version
-pyglib_version = _glib.pyglib_version
spawn_async = _glib.spawn_async
threads_init = _glib.threads_init
diff --git a/gi/_glib/glibmodule.c b/gi/_glib/glibmodule.c
index b360ec1..765fd5b 100644
--- a/gi/_glib/glibmodule.c
+++ b/gi/_glib/glibmodule.c
@@ -139,26 +139,6 @@ pyglib_register_error(PyObject *d)
}
static void
-pyglib_register_version_tuples(PyObject *d)
-{
- PyObject *o;
-
- /* glib version */
- o = Py_BuildValue("(iii)", glib_major_version, glib_minor_version,
- glib_micro_version);
- PyDict_SetItemString(d, "glib_version", o);
- Py_DECREF(o);
-
- /* pyglib version */
- o = Py_BuildValue("(iii)",
- PYGLIB_MAJOR_VERSION,
- PYGLIB_MINOR_VERSION,
- PYGLIB_MICRO_VERSION);
- PyDict_SetItemString(d, "pyglib_version", o);
- Py_DECREF(o);
-}
-
-static void
pyglib_register_constants(PyObject *m)
{
PyModule_AddIntConstant(m, "OPTION_FLAG_HIDDEN",
@@ -196,7 +176,6 @@ PYGLIB_MODULE_START(_glib, "_glib")
pyglib_register_constants(module);
pyglib_register_api(d);
pyglib_register_error(d);
- pyglib_register_version_tuples(d);
pyglib_source_register_types(d);
pyglib_spawn_register_types(d);
pyglib_option_context_register_types(d);
diff --git a/gi/_gobject/__init__.py b/gi/_gobject/__init__.py
index e0c08d8..2493cff 100644
--- a/gi/_gobject/__init__.py
+++ b/gi/_gobject/__init__.py
@@ -85,7 +85,6 @@ spawn_async = _glib.spawn_async
filename_from_utf8 = _glib.filename_from_utf8
Pid = _glib.Pid
GError = _glib.GError
-glib_version = _glib.glib_version
OptionGroup = _glib.OptionGroup
OptionContext = _glib.OptionContext
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index 2c03b6a..cb4a26b 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -26,7 +26,7 @@ from ..module import get_introspection_module
from .._gi import (variant_new_tuple, variant_type_from_string, source_new,
source_set_callback, io_channel_read)
from ..overrides import override, deprecated
-from gi import PyGIDeprecationWarning
+from gi import PyGIDeprecationWarning, version_info
GLib = get_introspection_module('GLib')
@@ -802,6 +802,12 @@ get_current_time = deprecated(get_current_time, 'GLib.get_real_time()')
__all__.append('get_current_time')
+# obsolete constants for backwards compatibility
+glib_version = (GLib.MAJOR_VERSION, GLib.MINOR_VERSION, GLib.MICRO_VERSION)
+__all__.append('glib_version')
+pyglib_version = version_info
+__all__.append('pyglib_version')
+
# work around wrong constants in GLib GIR, see
# https://bugzilla.gnome.org/show_bug.cgi?id=685022
MININT64 = -9223372036854775808
diff --git a/gi/overrides/GObject.py b/gi/overrides/GObject.py
index 0f2159b..704aa01 100644
--- a/gi/overrides/GObject.py
+++ b/gi/overrides/GObject.py
@@ -48,7 +48,8 @@ for name in ['PRIORITY_DEFAULT', 'PRIORITY_DEFAULT_IDLE', 'PRIORITY_HIGH',
'SPAWN_LEAVE_DESCRIPTORS_OPEN', 'SPAWN_DO_NOT_REAP_CHILD',
'SPAWN_SEARCH_PATH', 'SPAWN_STDOUT_TO_DEV_NULL',
'SPAWN_STDERR_TO_DEV_NULL', 'SPAWN_CHILD_INHERITS_STDIN',
- 'SPAWN_FILE_AND_ARGV_ZERO']:
+ 'SPAWN_FILE_AND_ARGV_ZERO',
+ 'glib_version']:
globals()[name] = getattr(GLib, name)
__all__.append(name)
diff --git a/tests/test_glib.py b/tests/test_glib.py
index 59004ae..336cc8e 100644
--- a/tests/test_glib.py
+++ b/tests/test_glib.py
@@ -179,3 +179,15 @@ https://my.org/q?x=1&y=2
self.assertEqual(call_data, [(cmd.stdout, GLib.IOCondition.IN, b'hello\n'),
(cmd.stdout, GLib.IOCondition.IN, b'world\n')])
+
+ def test_glib_version(self):
+ (major, minor, micro) = GLib.glib_version
+ self.assertGreaterEqual(major, 2)
+ self.assertGreaterEqual(minor, 0)
+ self.assertGreaterEqual(micro, 0)
+
+ def test_pyglib_version(self):
+ (major, minor, micro) = GLib.pyglib_version
+ self.assertGreaterEqual(major, 3)
+ self.assertGreaterEqual(minor, 7)
+ self.assertGreaterEqual(micro, 2)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]