From f9f43debc29ebef6942cd052d052e281ac25c214 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Wed, 25 Nov 2020 14:48:00 +0900 Subject: [PATCH] Imported Upstream version 3.30.5 --- .gitlab-ci.yml | 7 +++--- .gitlab-ci/test-docker.sh | 2 +- .gitlab-ci/test-msys2.sh | 15 ++++++------ NEWS | 9 ++++++++ examples/demo/demos/TreeView/treemodel_filelist.py | 8 +++---- examples/demo/demos/TreeView/treemodel_filetree.py | 8 +++---- gi/pygi-array.c | 2 +- gi/pygi-error.c | 27 +++++++++++----------- gi/pygobject-object.c | 5 +++- meson.build | 16 ++++++------- setup.py | 8 +++---- tests/gimarshallingtestsextra.c | 16 ++++++------- tests/gimarshallingtestsextra.h | 16 ++++++------- tests/test_overrides_gtk.py | 6 ++--- 14 files changed, 78 insertions(+), 67 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3a25c6a..64ba37a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -117,9 +117,8 @@ xenial-i386-py2: script: - bash -x ./.gitlab-ci/test-docker-old.sh -gnome-master: - allow_failure: true +gnome-runtime: stage: build_and_test - image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master + image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:3.30 script: - - xvfb-run -a flatpak run --filesystem=host --share=network --socket=x11 --command=bash org.gnome.Sdk//master -x .gitlab-ci/test-flatpak.sh + - xvfb-run -a flatpak run --filesystem=host --share=network --socket=x11 --command=bash org.gnome.Sdk//3.30 -x .gitlab-ci/test-flatpak.sh diff --git a/.gitlab-ci/test-docker.sh b/.gitlab-ci/test-docker.sh index 141d654..4837d51 100755 --- a/.gitlab-ci/test-docker.sh +++ b/.gitlab-ci/test-docker.sh @@ -37,7 +37,7 @@ else meson _build -Dpython="$(which python)" fi ninja -C _build -xvfb-run -a meson test -C _build -v +xvfb-run -a meson test --timeout-multiplier 4 -C _build -v rm -Rf _build # CODE QUALITY diff --git a/.gitlab-ci/test-msys2.sh b/.gitlab-ci/test-msys2.sh index 2b11aea..38d4fbc 100755 --- a/.gitlab-ci/test-msys2.sh +++ b/.gitlab-ci/test-msys2.sh @@ -51,10 +51,11 @@ export PYTHONDEVMODE=1 $PYTHON setup.py build_tests MSYSTEM= $PYTHON -m coverage run tests/runtests.py -curl -O -J -L "https://github.com/linux-test-project/lcov/archive/master.tar.gz" -tar -xvzf lcov-master.tar.gz - -./lcov-master/bin/lcov \ - --rc lcov_branch_coverage=1 --no-external \ - --directory . --capture --output-file \ - "${COV_DIR}/${COV_KEY}.lcov" +# FIXME: lcov doesn't support gcc9 +#~ curl -O -J -L "https://github.com/linux-test-project/lcov/archive/master.tar.gz" +#~ tar -xvzf lcov-master.tar.gz + +#~ ./lcov-master/bin/lcov \ + #~ --rc lcov_branch_coverage=1 --no-external \ + #~ --directory . --capture --output-file \ + #~ "${COV_DIR}/${COV_KEY}.lcov" diff --git a/NEWS b/NEWS index 940085b..6235c56 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,12 @@ +3.30.5 - 2019-06-16 +------------------- + +* tests/gimarshallingtestsextra.c/h: relicense to LGPLv2.1+ :issue:`320` +* Fix a crash when marshalling a GError to Python fails :mr:`115` +* Fix leak of transfer-full/container C arrays :mr:`117` (:user:`Tomasz Miąsko `) +* Python 3.8b1 compatibility fixes + + 3.30.4 - 2018-11-30 ------------------- diff --git a/examples/demo/demos/TreeView/treemodel_filelist.py b/examples/demo/demos/TreeView/treemodel_filelist.py index f011a47..82e6d95 100644 --- a/examples/demo/demos/TreeView/treemodel_filelist.py +++ b/examples/demo/demos/TreeView/treemodel_filelist.py @@ -125,16 +125,16 @@ class FileListModel(gtk.GenericTreeModel): except OSError: return None mode = filestat.st_mode - if column is 0: + if column == 0: if stat.S_ISDIR(mode): return folderpb else: return filepb - elif column is 1: + elif column == 1: return rowref - elif column is 2: + elif column == 2: return filestat.st_size - elif column is 3: + elif column == 3: return oct(stat.S_IMODE(mode)) return time.ctime(filestat.st_mtime) diff --git a/examples/demo/demos/TreeView/treemodel_filetree.py b/examples/demo/demos/TreeView/treemodel_filetree.py index 3b43190..eb8e2b9 100644 --- a/examples/demo/demos/TreeView/treemodel_filetree.py +++ b/examples/demo/demos/TreeView/treemodel_filetree.py @@ -157,16 +157,16 @@ class FileTreeModel(gtk.GenericTreeModel): except OSError: return None mode = filestat.st_mode - if column is 0: + if column == 0: if stat.S_ISDIR(mode): return folderpb else: return filepb - elif column is 1: + elif column == 1: return os.path.basename(relpath) - elif column is 2: + elif column == 2: return filestat.st_size - elif column is 3: + elif column == 3: return oct(stat.S_IMODE(mode)) return time.ctime(filestat.st_mtime) diff --git a/gi/pygi-array.c b/gi/pygi-array.c index 073e143..890e7c5 100644 --- a/gi/pygi-array.c +++ b/gi/pygi-array.c @@ -766,7 +766,7 @@ _pygi_marshal_cleanup_to_py_array (PyGIInvokeState *state, return; free_array = TRUE; - free_array_full = FALSE; + free_array_full = arg_cache->transfer != GI_TRANSFER_NOTHING; } else if (array_cache->array_type == GI_ARRAY_TYPE_PTR_ARRAY) { ptr_array_ = (GPtrArray *) data; } else { diff --git a/gi/pygi-error.c b/gi/pygi-error.c index 8e4a793..b0eeccd 100644 --- a/gi/pygi-error.c +++ b/gi/pygi-error.c @@ -36,8 +36,10 @@ PyObject *PyGError = NULL; * * Checks to see if @error has been set. If @error has been set, then a * GLib.GError Python exception object is returned (but not raised). + * If not error is set returns Py_None. * - * Returns: a GLib.GError Python exception object, or NULL. + * Returns: a GLib.GError Python exception object, or Py_None, + * or NULL and sets an error if creating the exception object fails. */ PyObject * pygi_error_marshal_to_py (GError **error) @@ -50,7 +52,7 @@ pygi_error_marshal_to_py (GError **error) g_return_val_if_fail(error != NULL, NULL); if (*error == NULL) - return NULL; + Py_RETURN_NONE; state = PyGILState_Ensure(); @@ -93,8 +95,13 @@ pygi_error_check (GError **error) state = PyGILState_Ensure(); exc_instance = pygi_error_marshal_to_py (error); - PyErr_SetObject(PyGError, exc_instance); - Py_DECREF(exc_instance); + if (exc_instance != NULL) { + PyErr_SetObject(PyGError, exc_instance); + Py_DECREF(exc_instance); + } else { + PyErr_Print (); + PyErr_SetString (PyExc_RuntimeError, "Converting the GError failed"); + } g_clear_error(error); PyGILState_Release(state); @@ -266,11 +273,7 @@ _pygi_marshal_to_py_gerror (PyGIInvokeState *state, g_error_free (error); } - if (py_obj != NULL) { - return py_obj; - } else { - Py_RETURN_NONE; - } + return py_obj; } static gboolean @@ -330,11 +333,7 @@ pygerror_from_gvalue (const GValue *value) { GError *gerror = (GError *) g_value_get_boxed (value); PyObject *pyerr = pygi_error_marshal_to_py (&gerror); - if (pyerr == NULL) { - Py_RETURN_NONE; - } else { - return pyerr; - } + return pyerr; } static int diff --git a/gi/pygobject-object.c b/gi/pygobject-object.c index dbf46e1..39c03ca 100644 --- a/gi/pygobject-object.c +++ b/gi/pygobject-object.c @@ -878,7 +878,10 @@ pygobject_inherit_slots(PyTypeObject *type, PyObject *bases, gboolean check_for_ offsetof(PyTypeObject, tp_iter), offsetof(PyTypeObject, tp_repr), offsetof(PyTypeObject, tp_str), - offsetof(PyTypeObject, tp_print) }; +#if PY_VERSION_HEX < 0x03000000 + offsetof(PyTypeObject, tp_print), +#endif + }; gsize i; /* Happens when registering gobject.GObject itself, at least. */ diff --git a/meson.build b/meson.build index fab0768..1b30bc1 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('pygobject', 'c', - version : '3.30.4', + version : '3.30.5', meson_version : '>= 0.46.0', default_options : [ 'warning_level=1', 'buildtype=debugoptimized']) @@ -72,7 +72,6 @@ else '-Wall', '-Warray-bounds', '-Wcast-align', - '-Wdeclaration-after-statement', '-Wduplicated-branches', '-Wextra', '-Wformat=2', @@ -98,11 +97,18 @@ else '-Wsign-compare', '-Wstrict-aliasing', '-Wstrict-prototypes', + '-Wswitch-default', '-Wundef', '-Wunused-but-set-variable', '-Wwrite-strings', ] + if python.language_version().split('.')[0] == '2' + main_c_args += [ + '-Wdeclaration-after-statement', + ] + endif + main_c_args += [ '-Wno-incompatible-pointer-types-discards-qualifiers', '-Wno-missing-field-initializers', @@ -118,12 +124,6 @@ else '-fvisibility=hidden', ] - if not ['3.3', '3.4'].contains(python.language_version()) - main_c_args += [ - '-Wswitch-default', - ] - endif - main_c_args = cc.get_supported_arguments(main_c_args) endif diff --git a/setup.py b/setup.py index 52f8f78..fc46a4c 100755 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ from distutils import dir_util, log from distutils.spawn import find_executable -PYGOBJECT_VERSION = "3.30.4" +PYGOBJECT_VERSION = "3.30.5" GLIB_VERSION_REQUIRED = "2.38.0" GI_VERSION_REQUIRED = "1.46.0" PYCAIRO_VERSION_REQUIRED = "1.11.1" @@ -937,7 +937,6 @@ def add_ext_compiler_flags(ext, compiler, _cache={}): "-Wall", "-Warray-bounds", "-Wcast-align", - "-Wdeclaration-after-statement", "-Wduplicated-branches", "-Wextra", "-Wformat=2", @@ -963,14 +962,15 @@ def add_ext_compiler_flags(ext, compiler, _cache={}): "-Wsign-compare", "-Wstrict-aliasing", "-Wstrict-prototypes", + "-Wswitch-default", "-Wundef", "-Wunused-but-set-variable", "-Wwrite-strings", ] - if sys.version_info[:2] != (3, 4): + if sys.version_info[0] == 2: args += [ - "-Wswitch-default", + "-Wdeclaration-after-statement", ] args += [ diff --git a/tests/gimarshallingtestsextra.c b/tests/gimarshallingtestsextra.c index 4debaf5..d4d6189 100644 --- a/tests/gimarshallingtestsextra.c +++ b/tests/gimarshallingtestsextra.c @@ -2,18 +2,18 @@ * * Copyright (C) 2016 Thibault Saunier * - * This file is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 3 of the - * License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This file is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . */ #include "gimarshallingtestsextra.h" diff --git a/tests/gimarshallingtestsextra.h b/tests/gimarshallingtestsextra.h index bc5f8fe..68ce1d1 100644 --- a/tests/gimarshallingtestsextra.h +++ b/tests/gimarshallingtestsextra.h @@ -2,18 +2,18 @@ * * Copyright (C) 2016 Thibault Saunier * - * This file is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 3 of the - * License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This file is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . */ #ifndef EXTRA_TESTS diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py index 643be5c..d83fa45 100644 --- a/tests/test_overrides_gtk.py +++ b/tests/test_overrides_gtk.py @@ -6,10 +6,10 @@ from __future__ import absolute_import import contextlib import unittest -import time import sys import gc import warnings +import timeit from .helper import ignore_gi_deprecation_warnings, capture_glib_warnings @@ -2069,12 +2069,12 @@ class TestTreeModel(unittest.TestCase): model = Gtk.ListStore(int, str) iterations = 2000 - start = time.clock() + start = timeit.default_timer() i = iterations while i > 0: model.append([1, 'hello']) i -= 1 - end = time.clock() + end = timeit.default_timer() sys.stderr.write('[%.0f µs/append] ' % ((end - start) * 1000000 / iterations)) def test_filter_new_default(self): -- 2.7.4