From db211b4c58ded8bc5ca7308d57e73d84b5776a9b Mon Sep 17 00:00:00 2001 From: ajacoutot Date: Fri, 20 Jul 2012 07:14:12 +0000 Subject: [PATCH] Escape identifiers which are Python keywords to avoid breaking the API between different Python versions, from upstream. tested in a bulk by jasper@ "get it in" naddy@ ok jasper@ --- devel/py-gobject3/Makefile | 3 +- devel/py-gobject3/distinfo | 3 -- .../py-gobject3/patches/patch-gi_pygi-info_c | 54 +++++++++++++++++++ 3 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 devel/py-gobject3/patches/patch-gi_pygi-info_c diff --git a/devel/py-gobject3/Makefile b/devel/py-gobject3/Makefile index 2996d8b8439..52ae6ee9bd7 100644 --- a/devel/py-gobject3/Makefile +++ b/devel/py-gobject3/Makefile @@ -1,9 +1,10 @@ -# $OpenBSD: Makefile,v 1.9 2012/05/14 17:18:16 ajacoutot Exp $ +# $OpenBSD: Makefile,v 1.10 2012/07/20 07:14:12 ajacoutot Exp $ COMMENT= Python bindings for glib2 gobject GNOME_PROJECT= pygobject GNOME_VERSION= 3.2.2 +REVISION= 0 PKGNAME= py-gobject3-${GNOME_VERSION} diff --git a/devel/py-gobject3/distinfo b/devel/py-gobject3/distinfo index ec8095d6a7a..5dfa4b94ebb 100644 --- a/devel/py-gobject3/distinfo +++ b/devel/py-gobject3/distinfo @@ -1,5 +1,2 @@ -MD5 (pygobject-3.2.2.tar.xz) = +JXx7Df2DCulKMLXYLy2ng== -RMD160 (pygobject-3.2.2.tar.xz) = CQ+klB+jDmiILiWFbZIjDr3Qzqk= -SHA1 (pygobject-3.2.2.tar.xz) = s0QFNX1pQSZXkEd1ogekqDV6k00= SHA256 (pygobject-3.2.2.tar.xz) = RlN5C6r/AXb9gUuIz7U3jEWQahILJdAb4lVPQjtybrA= SIZE (pygobject-3.2.2.tar.xz) = 564712 diff --git a/devel/py-gobject3/patches/patch-gi_pygi-info_c b/devel/py-gobject3/patches/patch-gi_pygi-info_c new file mode 100644 index 00000000000..e0a2598e3e0 --- /dev/null +++ b/devel/py-gobject3/patches/patch-gi_pygi-info_c @@ -0,0 +1,54 @@ +$OpenBSD: patch-gi_pygi-info_c,v 1.1 2012/07/20 07:14:12 ajacoutot Exp $ + +From 16280d6985f2cf4db9cf062e857650e620fd9da8 Mon Sep 17 00:00:00 2001 +From: Martin Pitt +Date: Mon, 25 Jun 2012 07:40:38 +0000 +Subject: Escape identifiers which are Python keywords + +--- gi/pygi-info.c.orig Mon May 14 18:49:12 2012 ++++ gi/pygi-info.c Wed Jul 18 17:41:11 2012 +@@ -95,7 +95,43 @@ PYGLIB_DEFINE_TYPE("gi.BaseInfo", PyGIBaseInfo_Type, P + static PyObject * + _wrap_g_base_info_get_name (PyGIBaseInfo *self) + { +- return PYGLIB_PyUnicode_FromString (g_base_info_get_name (self->info)); ++ /* It may be better to use keyword.iskeyword(); keep in sync with ++ * python -c 'import keyword; print(keyword.kwlist)' */ ++#if PY_VERSION_HEX < 0x03000000 ++ /* Python 2.x */ ++ static const gchar* keywords[] = {"and", "as", "assert", "break", "class", ++ "continue", "def", "del", "elif", "else", "except", "exec", "finally", ++ "for", "from", "global", "if", "import", "in", "is", "lambda", "not", ++ "or", "pass", "print", "raise", "return", "try", "while", "with", ++ "yield", NULL}; ++#elif PY_VERSION_HEX < 0x04000000 ++ /* Python 3.x; note that we explicitly keep "print"; it is not a keyword ++ * any more, but we do not want to break API between Python versions */ ++ static const gchar* keywords[] = {"False", "None", "True", "and", "as", ++ "assert", "break", "class", "continue", "def", "del", "elif", "else", ++ "except", "finally", "for", "from", "global", "if", "import", "in", ++ "is", "lambda", "nonlocal", "not", "or", "pass", "raise", "return", ++ "try", "while", "with", "yield", ++ "print", NULL}; ++#else ++ #error Need keyword list for this major Python version ++#endif ++ ++ const gchar *name, **i; ++ ++ name = g_base_info_get_name (self->info); ++ ++ /* escape keywords */ ++ for (i = keywords; *i != NULL; ++i) { ++ if (strcmp (name, *i) == 0) { ++ gchar *escaped = g_strconcat (name, "_", NULL); ++ PyObject *obj = PYGLIB_PyUnicode_FromString (escaped); ++ g_free (escaped); ++ return obj; ++ } ++ } ++ ++ return PYGLIB_PyUnicode_FromString (name); + } + + static PyObject *