Compare commits

...

1 Commits
master ... f25

Author SHA1 Message Date
Parag A Nemade d980da8149
Resolves:rh#1430124 - can't import fontforge and psMat python modules 2017-03-08 10:37:02 +05:30
2 changed files with 54 additions and 1 deletions

View File

@ -0,0 +1,47 @@
From 3c57c9c2482c39c9f5f18f41bda93090d2fc9a17 Mon Sep 17 00:00:00 2001
From: Jeremy Tan <jtanx@outlook.com>
Date: Tue, 4 Oct 2016 20:42:15 +0800
Subject: [PATCH] Python3 scripting: Don't call RegisterAllPyModules from
imported modules
This calls PyImport_AppendInittab. The behaviour has changed between
Python 2 and 3. In 3, you cannot call this function anymore after
Py_Initialize has been called. Meaning since the module has already
been imported, Py_Initialize must have already been called before.
This change means that FFPY_PYTHON_ENTRY_FUNCTION will now be called
more than once (once for each module imported) on Python 3, so ensure
that the initialisation code only runs once.
Fixes #2886. See also #1731.
---
fontforge/python.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/fontforge/python.c b/fontforge/python.c
index 538b907..238f0dd 100644
--- a/fontforge/python.c
+++ b/fontforge/python.c
@@ -18893,11 +18893,18 @@ return;
** function.
*/
PyMODINIT_FUNC FFPY_PYTHON_ENTRY_FUNCTION(const char* modulename) {
- doinitFontForgeMain();
- no_windowing_ui = running_script = true;
+ static int initted = false;
- RegisterAllPyModules();
- CreateAllPyModules();
+ if (!initted) {
+ doinitFontForgeMain();
+ no_windowing_ui = running_script = true;
+
+#if PY_MAJOR_VERSION <= 2
+ RegisterAllPyModules();
+#endif
+ CreateAllPyModules();
+ initted = true;
+ }
#if PY_MAJOR_VERSION >= 3
/* Python 3 expects the module object to be returned */

View File

@ -4,7 +4,7 @@
Name: fontforge
Version: 20160404
Release: 4%{?dist}
Release: 5%{?dist}
Summary: Outline and bitmap font editor
License: GPLv3+
@ -15,6 +15,8 @@ Source1: http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=snapshot;h=%{
# https://github.com/fontforge/fontforge/pull/1723
Patch0: fontforge-20140813-use-system-uthash.patch
Patch1: Add-python3-support.patch
# https://github.com/jtanx/fontforge/commit/3c57c9c2482c39c9f5f18f41bda93090d2fc9a17.patch
Patch2: fontforge-20160404-python3-import-psMat-fix.patch
Requires: xdg-utils
Requires: autotrace
@ -77,6 +79,7 @@ tar xzf %{SOURCE1}
%patch0 -p0
%patch1 -p1
%patch2 -p1
sed -i -e '/^#!\//, 1d' pycontrib/webcollab.py
mkdir htdocs
@ -169,6 +172,9 @@ fi
%doc htdocs
%changelog
* Wed Mar 08 2017 Parag Nemade <pnemade AT redhat DOT com> - 20160404-5
- Resolves:rh#1430124 - can't import fontforge and psMat python modules
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 20160404-4
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages