[pygobject] Remove gi._gi._glib module
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Remove gi._gi._glib module
- Date: Sat, 1 Apr 2017 09:46:25 +0000 (UTC)
commit bdfafd2bdc84d961bd2df43d8dee690177c77a56
Author: Christoph Reiter <creiter src gnome org>
Date: Mon Mar 27 07:39:22 2017 +0200
Remove gi._gi._glib module
Move the code into gi._gi (gimodule)
The module was a leftover from https://bugzilla.gnome.org/show_bug.cgi?id=712197
https://bugzilla.gnome.org/show_bug.cgi?id=735206
gi/Makefile.am | 1 -
gi/_option.py | 12 +++++-----
gi/gimodule.c | 31 ++++++++++++++------------
gi/glibmodule.c | 56 -------------------------------------------------
gi/overrides/GLib.py | 10 ++++----
gi/pygoptioncontext.c | 4 +-
gi/pygoptiongroup.c | 4 +-
gi/pygspawn.c | 14 ++++++------
8 files changed, 39 insertions(+), 93 deletions(-)
---
diff --git a/gi/Makefile.am b/gi/Makefile.am
index 9a8b7ec..90b6f84 100644
--- a/gi/Makefile.am
+++ b/gi/Makefile.am
@@ -55,7 +55,6 @@ _gi_la_SOURCES = \
pygpointer.h \
pygtype.c \
pygtype.h \
- glibmodule.c \
pygoptioncontext.c \
pygoptioncontext.h \
pygoptiongroup.c \
diff --git a/gi/_option.py b/gi/_option.py
index eb711e1..1a514cb 100644
--- a/gi/_option.py
+++ b/gi/_option.py
@@ -40,7 +40,7 @@ else:
_basestring = basestring
_bytes = str
-from gi._gi import _glib
+from gi import _gi
from gi._error import GError
GLib = get_introspection_module('GLib')
@@ -209,7 +209,7 @@ class OptionGroup(optparse.OptionGroup):
gerror.message = str(error)
raise gerror
- group = _glib.OptionGroup(self.name, self.description,
+ group = _gi.OptionGroup(self.name, self.description,
self.help_description, callback)
if self.translation_domain:
group.set_translation_domain(self.translation_domain)
@@ -285,12 +285,12 @@ class OptionParser(optparse.OptionParser):
parameter_string = self.usage + " - " + self.description
else:
parameter_string = self.usage
- context = _glib.OptionContext(parameter_string)
+ context = _gi.OptionContext(parameter_string)
context.set_help_enabled(self.help_enabled)
context.set_ignore_unknown_options(self.ignore_unknown_options)
for option_group in self.option_groups:
- if isinstance(option_group, _glib.OptionGroup):
+ if isinstance(option_group, _gi.OptionGroup):
g_group = option_group
else:
g_group = option_group.get_option_group(self)
@@ -303,7 +303,7 @@ class OptionParser(optparse.OptionParser):
opt = self._short_opt[option_name]
opt.process(option_name, option_value, values, self)
- main_group = _glib.OptionGroup(None, None, None, callback)
+ main_group = _gi.OptionGroup(None, None, None, callback)
main_entries = []
for option in self.option_list:
main_entries.extend(option._to_goptionentries())
@@ -323,7 +323,7 @@ class OptionParser(optparse.OptionParser):
args[0].parser = self
if args[0].parser is not self:
raise ValueError("invalid OptionGroup (wrong parser)")
- if isinstance(args[0], _glib.OptionGroup):
+ if isinstance(args[0], _gi.OptionGroup):
self.option_groups.append(args[0])
return
optparse.OptionParser.add_option_group(self, *args, **kwargs)
diff --git a/gi/gimodule.c b/gi/gimodule.c
index 65e10e4..69fa013 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -43,6 +43,9 @@
#include "pygi-boxed.h"
#include "pygi-info.h"
#include "pygi-struct.h"
+#include "pygoptioncontext.h"
+#include "pygoptiongroup.h"
+#include "pygspawn.h"
#include <pyglib-python-compat.h>
@@ -629,6 +632,15 @@ static PyMethodDef _gi_functions[] = {
{ "source_set_callback", (PyCFunction) pyg_source_set_callback, METH_VARARGS },
{ "io_channel_read", (PyCFunction) pyg_channel_read, METH_VARARGS },
{ "require_foreign", (PyCFunction) pygi_require_foreign, METH_VARARGS | METH_KEYWORDS },
+ { "spawn_async",
+ (PyCFunction)pyglib_spawn_async, METH_VARARGS|METH_KEYWORDS,
+ "spawn_async(argv, envp=None, working_directory=None,\n"
+ " flags=0, child_setup=None, user_data=None,\n"
+ " standard_input=None, standard_output=None,\n"
+ " standard_error=None) -> (pid, stdin, stdout, stderr)\n"
+ "\n"
+ "Execute a child program asynchronously within a glib.MainLoop()\n"
+ "See the reference manual for a complete reference.\n" },
{ NULL, NULL, 0 }
};
@@ -639,8 +651,8 @@ static struct PyGI_API CAPI = {
PYGLIB_MODULE_START(_gi, "_gi")
{
PyObject *api;
- PyObject *_glib_module;
PyObject *_gobject_module;
+ PyObject *module_dict = PyModule_GetDict (module);
/* Always enable Python threads since we cannot predict which GI repositories
* might accept Python callbacks run within non-Python threads or might trigger
@@ -649,19 +661,6 @@ PYGLIB_MODULE_START(_gi, "_gi")
*/
PyEval_InitThreads ();
- _glib_module = pyglib__glib_module_create ();
- if (_glib_module == NULL) {
- return PYGLIB_MODULE_ERROR_RETURN;
- }
- /* In Python 2.x, pyglib_..._module_create returns a borrowed reference and
- * PyModule_AddObject steals a reference. Ensure we don't share a reference
- * between sys.modules and gi._gi._glib by incrementing the ref count here.
- * Note that we don't add this to the PYGLIB_MODULE_START macro because that
- * would cause a leak for the main module gi._gi */
- if (PY_MAJOR_VERSION < 3) {
- Py_INCREF (_glib_module);
- }
- PyModule_AddObject (module, "_glib", _glib_module);
PyModule_AddStringConstant(module, "__package__", "gi._gi");
_gobject_module = pyglib__gobject_module_create ();
@@ -683,6 +682,10 @@ PYGLIB_MODULE_START(_gi, "_gi")
_pygi_ccallback_register_types (module);
pygi_resulttuple_register_types (module);
+ pyglib_spawn_register_types (module_dict);
+ pyglib_option_context_register_types (module_dict);
+ pyglib_option_group_register_types (module_dict);
+
PyGIWarning = PyErr_NewException ("gi.PyGIWarning", PyExc_Warning, NULL);
/* Use RuntimeWarning as the base class of PyGIDeprecationWarning
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index ab0e83a..a146380 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -40,15 +40,15 @@ __all__.append('option')
# Types and functions still needed from static bindings
-from gi._gi import _glib
+from gi import _gi
from gi._gi import _gobject
from gi._error import GError
Error = GError
-OptionContext = _glib.OptionContext
-OptionGroup = _glib.OptionGroup
-Pid = _glib.Pid
-spawn_async = _glib.spawn_async
+OptionContext = _gi.OptionContext
+OptionGroup = _gi.OptionGroup
+Pid = _gi.Pid
+spawn_async = _gi.spawn_async
def threads_init():
diff --git a/gi/pygoptioncontext.c b/gi/pygoptioncontext.c
index 3b2babd..50c32fb 100644
--- a/gi/pygoptioncontext.c
+++ b/gi/pygoptioncontext.c
@@ -26,7 +26,7 @@
#include "pygoptioncontext.h"
#include "pygi-error.h"
-PYGLIB_DEFINE_TYPE("gi._glib.OptionContext", PyGOptionContext_Type, PyGOptionContext)
+PYGLIB_DEFINE_TYPE("gi._gi.OptionContext", PyGOptionContext_Type, PyGOptionContext)
/**
* pyg_option_context_new:
@@ -56,7 +56,7 @@ pyg_option_context_init(PyGOptionContext *self,
{
char *parameter_string;
- if (!PyArg_ParseTuple(args, "s:gi._glib.GOptionContext.__init__",
+ if (!PyArg_ParseTuple(args, "s:gi._gi.GOptionContext.__init__",
¶meter_string))
return -1;
diff --git a/gi/pygoptiongroup.c b/gi/pygoptiongroup.c
index 6ea1964..e91ca05 100644
--- a/gi/pygoptiongroup.c
+++ b/gi/pygoptiongroup.c
@@ -26,7 +26,7 @@
#include "pygoptiongroup.h"
#include "pygi-error.h"
-PYGLIB_DEFINE_TYPE("gi._glib.OptionGroup", PyGOptionGroup_Type, PyGOptionGroup)
+PYGLIB_DEFINE_TYPE("gi._gi.OptionGroup", PyGOptionGroup_Type, PyGOptionGroup)
/**
* pyg_option_group_new:
@@ -60,7 +60,7 @@ check_if_owned(PyGOptionGroup *self)
if (self->other_owner)
{
PyErr_SetString(PyExc_ValueError, "The GOptionGroup was not created by "
- "gi._glib.OptionGroup(), so operation is not possible.");
+ "gi._gi.OptionGroup(), so operation is not possible.");
return TRUE;
}
return FALSE;
diff --git a/gi/pygspawn.c b/gi/pygspawn.c
index b7305eb..7828d23 100644
--- a/gi/pygspawn.c
+++ b/gi/pygspawn.c
@@ -32,7 +32,7 @@ struct _PyGChildSetupData {
PyObject *data;
};
-PYGLIB_DEFINE_TYPE("gi._glib.Pid", PyGPid_Type, PYGLIB_PyLongObject)
+PYGLIB_DEFINE_TYPE("gi._gi.Pid", PyGPid_Type, PYGLIB_PyLongObject)
static GPid
pyg_pid_get_pid (PyObject *self)
@@ -67,7 +67,7 @@ pyg_pid_free(PyObject *gpid)
static int
pyg_pid_tp_init(PyObject *self, PyObject *args, PyObject *kwargs)
{
- PyErr_SetString(PyExc_TypeError, "gi._glib.Pid cannot be manually instantiated");
+ PyErr_SetString(PyExc_TypeError, "gi._gi.Pid cannot be manually instantiated");
return -1;
}
@@ -125,7 +125,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs)
GPid child_pid = 0;
Py_ssize_t len, i;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OsiOOOOO:gi._glib.spawn_async",
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OsiOOOOO:gi._gi.spawn_async",
kwlist,
&pyargv, &pyenvp, &working_directory, &flags,
&func, &user_data,
@@ -150,7 +150,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs)
/* parse argv */
if (!PySequence_Check(pyargv)) {
PyErr_SetString(PyExc_TypeError,
- "gi._glib.spawn_async: "
+ "gi._gi.spawn_async: "
"first argument must be a sequence of strings");
return NULL;
}
@@ -160,7 +160,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs)
PyObject *tmp = PySequence_ITEM(pyargv, i);
if (tmp == NULL || !PYGLIB_PyUnicode_Check(tmp)) {
PyErr_SetString(PyExc_TypeError,
- "gi._glib.spawn_async: "
+ "gi._gi.spawn_async: "
"first argument must be a sequence of strings");
g_free(argv);
Py_XDECREF(tmp);
@@ -174,7 +174,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs)
if (pyenvp) {
if (!PySequence_Check(pyenvp)) {
PyErr_SetString(PyExc_TypeError,
- "gi._glib.spawn_async: "
+ "gi._gi.spawn_async: "
"second argument must be a sequence of strings");
g_free(argv);
return NULL;
@@ -185,7 +185,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs)
PyObject *tmp = PySequence_ITEM(pyenvp, i);
if (tmp == NULL || !PYGLIB_PyUnicode_Check(tmp)) {
PyErr_SetString(PyExc_TypeError,
- "gi._glib.spawn_async: "
+ "gi._gi.spawn_async: "
"second argument must be a sequence of strings");
g_free(envp);
Py_XDECREF(tmp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]