Commit 8d52bceb authored by Martin Pitt's avatar Martin Pitt
Browse files

Drop static glib_version and pyglib_version constants

Use the GLib version from GI instead, and the already existing gi.version_info.
parent 9f96325e
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<refentry id="glib-constants">
<refnamediv>
<refname>glib Constants</refname>
<refpurpose>the built-in constants of the glib module</refpurpose>
</refnamediv>
<refsect1>
<title>Synopsis</title>
<programlisting>
<xref linkend="glib-version-constants" endterm="glib-version-constants-title"></xref>
</programlisting>
</refsect1>
<refsect1 id="glib-constants-description">
<title>Description</title>
<refsect2 id="glib-version-constants">
<title id="glib-version-constants-title">Glib Version Constants</title>
<para>The Version constants specify the version of
<literal>Glib</literal> used by PyGObject as a 3-tuple containing the major,
minor and patch release numbers.</para>
<variablelist>
<varlistentry>
<term><literal>glib.glib_version</literal></term>
<listitem>
<simpara>A 3-tuple containing (major, minor, patch) release
numbers of glib.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>glib.pyglib_version</literal></term>
<listitem>
<simpara>A 3-tuple containing (major, minor, patch) release
numbers of the python bindings.</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
</refentry>
......@@ -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>
......@@ -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
......@@ -138,26 +138,6 @@ pyglib_register_error(PyObject *d)
pyglib_api.gerror_exception = gerror_class;
}
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)
{
......@@ -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);
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment