diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:48:01 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:48:04 +0900 |
commit | d80fc1d31f28c6bcf9ea34b253e8765321616c3c (patch) | |
tree | 53afc44a25c72df0a698294b6be95695dfa643ba /gi | |
parent | 52620756e3ccf2925e140a254d340d3ba29f3ad5 (diff) | |
download | pygobject2-d80fc1d31f28c6bcf9ea34b253e8765321616c3c.tar.gz pygobject2-d80fc1d31f28c6bcf9ea34b253e8765321616c3c.tar.bz2 pygobject2-d80fc1d31f28c6bcf9ea34b253e8765321616c3c.zip |
Imported Upstream version 3.7.1
Change-Id: I4c5c3aae69e883da127f15b41c102f953e8cc74c
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi')
-rw-r--r-- | gi/Makefile.in | 6 | ||||
-rw-r--r-- | gi/_glib/Makefile.in | 6 | ||||
-rw-r--r-- | gi/_glib/glibmodule.c | 8 | ||||
-rw-r--r-- | gi/_glib/pygiochannel.c | 25 | ||||
-rw-r--r-- | gi/_gobject/Makefile.in | 6 | ||||
-rw-r--r-- | gi/_gobject/__init__.py | 45 | ||||
-rw-r--r-- | gi/_gobject/propertyhelper.py | 45 | ||||
-rw-r--r-- | gi/overrides/GLib.py | 8 | ||||
-rw-r--r-- | gi/overrides/Makefile.in | 6 | ||||
-rw-r--r-- | gi/pygi-marshal-from-py.c | 31 | ||||
-rw-r--r-- | gi/repository/Makefile.in | 6 |
11 files changed, 80 insertions, 112 deletions
diff --git a/gi/Makefile.in b/gi/Makefile.in index 1bbd583..72838c4 100644 --- a/gi/Makefile.in +++ b/gi/Makefile.in @@ -61,10 +61,8 @@ DIST_COMMON = $(pygi_PYTHON) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ - $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/python.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/python.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/gi/_glib/Makefile.in b/gi/_glib/Makefile.in index e87f9b2..fa858e0 100644 --- a/gi/_glib/Makefile.in +++ b/gi/_glib/Makefile.in @@ -61,10 +61,8 @@ DIST_COMMON = $(pyglib_PYTHON) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ - $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/python.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/python.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/gi/_glib/glibmodule.c b/gi/_glib/glibmodule.c index 7d70a07..11b97f5 100644 --- a/gi/_glib/glibmodule.c +++ b/gi/_glib/glibmodule.c @@ -313,7 +313,7 @@ pyglib_source_remove(PyObject *self, PyObject *args) { guint tag; - if (!PyArg_ParseTuple(args, "I:source_remove", &tag)) + if (!PyArg_ParseTuple(args, "i:source_remove", &tag)) return NULL; return PyBool_FromLong(g_source_remove(tag)); @@ -351,15 +351,9 @@ static void child_watch_dnotify(gpointer data) { struct _PyGChildData *child_data = (struct _PyGChildData *) data; - PyGILState_STATE gil; - - gil = pyglib_gil_state_ensure(); - Py_DECREF(child_data->func); Py_XDECREF(child_data->data); g_slice_free(struct _PyGChildData, child_data); - - pyglib_gil_state_release(gil); } diff --git a/gi/_glib/pygiochannel.c b/gi/_glib/pygiochannel.c index 722fd0d..0288145 100644 --- a/gi/_glib/pygiochannel.c +++ b/gi/_glib/pygiochannel.c @@ -191,7 +191,7 @@ py_io_channel_read_chars(PyGIOChannel* self, PyObject *args, PyObject *kwargs) return NULL; if (max_count == 0) - return PYGLIB_PyBytes_FromString(""); + return PYGLIB_PyUnicode_FromString(""); while (status == G_IO_STATUS_NORMAL && (max_count == -1 || total_read < max_count)) { @@ -234,6 +234,23 @@ py_io_channel_read_chars(PyGIOChannel* self, PyObject *args, PyObject *kwargs) goto failure; } +#if PY_VERSION_HEX >= 0x03000000 + /* If this is not UTF8 encoded channel return the raw bytes */ + if (g_io_channel_get_encoding(self->channel) != NULL) + return ret_obj; + + /* convert to Unicode string */ + { + PyObject *unicode_obj; + + unicode_obj = PyUnicode_FromString(PyBytes_AS_STRING(ret_obj)); + if (unicode_obj == NULL) + goto failure; + Py_DECREF(ret_obj); + ret_obj = unicode_obj; + } +#endif + return ret_obj; failure: @@ -281,11 +298,9 @@ py_io_channel_write_lines(PyGIOChannel* self, PyObject *args, PyObject *kwargs) while (1) { value = PyIter_Next(iter); - if (value == NULL) - break; if (PyErr_ExceptionMatches(PyExc_StopIteration)) { PyErr_Clear(); - break; + goto normal_exit; } if (!PYGLIB_PyUnicode_Check(value)) { PyErr_SetString(PyExc_TypeError, "gi._glib.IOChannel.writelines must" @@ -303,7 +318,7 @@ py_io_channel_write_lines(PyGIOChannel* self, PyObject *args, PyObject *kwargs) return NULL; } } - +normal_exit: Py_DECREF(iter); Py_INCREF(Py_None); return Py_None; diff --git a/gi/_gobject/Makefile.in b/gi/_gobject/Makefile.in index fec095b..f66bd46 100644 --- a/gi/_gobject/Makefile.in +++ b/gi/_gobject/Makefile.in @@ -60,10 +60,8 @@ DIST_COMMON = $(pkginclude_HEADERS) $(pygobject_PYTHON) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ - $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/python.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/python.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/gi/_gobject/__init__.py b/gi/_gobject/__init__.py index 7b6ab36..f12d3fe 100644 --- a/gi/_gobject/__init__.py +++ b/gi/_gobject/__init__.py @@ -30,7 +30,7 @@ if 'gobject' in sys.modules: from .. import _glib from . import _gobject from . import constants -from .propertyhelper import Property +from . import propertyhelper from . import signalhelper GBoxed = _gobject.GBoxed @@ -211,6 +211,7 @@ G_MAXSSIZE = constants.G_MAXSSIZE G_MINOFFSET = constants.G_MINOFFSET G_MAXOFFSET = constants.G_MAXOFFSET +Property = propertyhelper.Property Signal = signalhelper.Signal SignalOverride = signalhelper.SignalOverride @@ -222,50 +223,10 @@ class GObjectMeta(type): "Metaclass for automatically registering GObject classes" def __init__(cls, name, bases, dict_): type.__init__(cls, name, bases, dict_) - cls._install_properties() + propertyhelper.install_properties(cls) signalhelper.install_signals(cls) cls._type_register(cls.__dict__) - def _install_properties(cls): - gproperties = getattr(cls, '__gproperties__', {}) - - props = [] - for name, prop in cls.__dict__.items(): - if isinstance(prop, Property): # not same as the built-in - if name in gproperties: - raise ValueError - prop.name = name - gproperties[name] = prop.get_pspec_args() - props.append(prop) - - if not props: - return - - cls.__gproperties__ = gproperties - - if 'do_get_property' in cls.__dict__ or 'do_set_property' in cls.__dict__: - for prop in props: - if prop.fget != prop._default_getter or prop.fset != prop._default_setter: - raise TypeError( - "GObject subclass %r defines do_get/set_property" - " and it also uses a property with a custom setter" - " or getter. This is not allowed" % ( - cls.__name__,)) - - def obj_get_property(self, pspec): - name = pspec.name.replace('-', '_') - prop = getattr(cls, name, None) - if prop: - return prop.fget(self) - cls.do_get_property = obj_get_property - - def obj_set_property(self, pspec, value): - name = pspec.name.replace('-', '_') - prop = getattr(cls, name, None) - if prop: - prop.fset(self, value) - cls.do_set_property = obj_set_property - def _type_register(cls, namespace): ## don't register the class if already registered if '__gtype__' in namespace: diff --git a/gi/_gobject/propertyhelper.py b/gi/_gobject/propertyhelper.py index 82b06b0..d6deb6d 100644 --- a/gi/_gobject/propertyhelper.py +++ b/gi/_gobject/propertyhelper.py @@ -343,3 +343,48 @@ class Property(object): raise NotImplementedError(ptype) return (self.type, self.nick, self.blurb) + args + (self.flags,) + + +def install_properties(cls): + """ + Scans the given class for instances of Property and merges them + into the classes __gproperties__ dict if it exists or adds it if not. + """ + gproperties = cls.__dict__.get('__gproperties__', {}) + + props = [] + for name, prop in cls.__dict__.items(): + if isinstance(prop, Property): # not same as the built-in + if name in gproperties: + raise ValueError('Property %s was already found in __gproperties__' % name) + prop.name = name + gproperties[name] = prop.get_pspec_args() + props.append(prop) + + if not props: + return + + cls.__gproperties__ = gproperties + + if 'do_get_property' in cls.__dict__ or 'do_set_property' in cls.__dict__: + for prop in props: + if prop.fget != prop._default_getter or prop.fset != prop._default_setter: + raise TypeError( + "GObject subclass %r defines do_get/set_property" + " and it also uses a property with a custom setter" + " or getter. This is not allowed" % ( + cls.__name__,)) + + def obj_get_property(self, pspec): + name = pspec.name.replace('-', '_') + prop = getattr(cls, name, None) + if prop: + return prop.fget(self) + cls.do_get_property = obj_get_property + + def obj_set_property(self, pspec, value): + name = pspec.name.replace('-', '_') + prop = getattr(cls, name, None) + if prop: + prop.fset(self, value) + cls.do_set_property = obj_set_property diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py index cc5dea2..b6f2ce2 100644 --- a/gi/overrides/GLib.py +++ b/gi/overrides/GLib.py @@ -406,11 +406,3 @@ setattr(Variant, 'new_tuple', new_tuple) setattr(Variant, 'get_string', get_string) __all__.append('Variant') - - -# work around wrong constants in GLib GIR, see -# https://bugzilla.gnome.org/show_bug.cgi?id=685022 -MININT64 = -9223372036854775808 -MAXUINT64 = 18446744073709551615 -__all__.append('MININT64') -__all__.append('MAXUINT64') diff --git a/gi/overrides/Makefile.in b/gi/overrides/Makefile.in index 2c78fe1..bb0f0d9 100644 --- a/gi/overrides/Makefile.in +++ b/gi/overrides/Makefile.in @@ -55,10 +55,8 @@ DIST_COMMON = $(pygioverrides_PYTHON) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ - $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/python.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/python.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c index c20e023..b4c9fa0 100644 --- a/gi/pygi-marshal-from-py.c +++ b/gi/pygi-marshal-from-py.c @@ -40,39 +40,11 @@ gi_argument_from_py_ssize_t (GIArgument *arg_out, switch (type_tag) { case GI_TYPE_TAG_VOID: case GI_TYPE_TAG_BOOLEAN: - goto unhandled_type; - case GI_TYPE_TAG_INT8: - if (size_in >= G_MININT8 && size_in <= G_MAXINT8) { - arg_out->v_int8 = size_in; - return TRUE; - } else { - goto overflow; - } - case GI_TYPE_TAG_UINT8: - if (size_in >= 0 && size_in <= G_MAXUINT8) { - arg_out->v_uint8 = size_in; - return TRUE; - } else { - goto overflow; - } - case GI_TYPE_TAG_INT16: - if (size_in >= G_MININT16 && size_in <= G_MAXINT16) { - arg_out->v_int16 = size_in; - return TRUE; - } else { - goto overflow; - } - case GI_TYPE_TAG_UINT16: - if (size_in >= 0 && size_in <= G_MAXUINT16) { - arg_out->v_uint16 = size_in; - return TRUE; - } else { - goto overflow; - } + goto unhandled_type; /* Ranges assume two's complement */ case GI_TYPE_TAG_INT32: @@ -930,7 +902,6 @@ _pygi_marshal_from_py_array (PyGIInvokeState *state, if (sequence_cache->item_cache->type_tag == GI_TYPE_TAG_UINT8 && PYGLIB_PyBytes_Check (py_arg)) { memcpy(array_->data, PYGLIB_PyBytes_AsString (py_arg), length); - array_->len = length; if (sequence_cache->is_zero_terminated) { /* If array_ has been created with zero_termination, space for the * terminator is properly allocated, so we're not off-by-one here. */ diff --git a/gi/repository/Makefile.in b/gi/repository/Makefile.in index b6f258b..05006f1 100644 --- a/gi/repository/Makefile.in +++ b/gi/repository/Makefile.in @@ -55,10 +55,8 @@ DIST_COMMON = $(pygirepository_PYTHON) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ - $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/python.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/python.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d |