Skip to content

Commit 9bccbb1

Browse files
committed
fix calling exit() in PIL if re-initialized.
1 parent 18cbe28 commit 9bccbb1

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

pythonforandroid/recipes/pil/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class PILRecipe(CompiledComponentsPythonRecipe):
1111
site_packages_name = 'PIL'
1212

1313
patches = ['disable-tk.patch',
14-
'fix-directories.patch']
14+
'fix-directories.patch',
15+
'fix-reinit-access.patch']
1516

1617
def get_recipe_env(self, arch=None):
1718
env = super(PILRecipe, self).get_recipe_env(arch)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--- Imaging-1.1.7/_imaging.c.orig 2016-08-16 11:22:50.645124791 +0700
2+
+++ Imaging-1.1.7/_imaging.c 2016-08-16 11:22:30.833125194 +0700
3+
@@ -3251,6 +3251,7 @@
4+
{
5+
PyObject* m;
6+
PyObject* d;
7+
+ static int is_init = 0;
8+
9+
/* Patch object type */
10+
Imaging_Type.ob_type = &PyType_Type;
11+
@@ -3260,7 +3261,13 @@
12+
#endif
13+
PixelAccess_Type.ob_type = &PyType_Type;
14+
15+
- ImagingAccessInit();
16+
+ /* FIXME: prevent exit(1) in libImaging/Access.c due to hash collision
17+
+ * if it's re-initialized.
18+
+ */
19+
+ if (!is_init) {
20+
+ ImagingAccessInit();
21+
+ is_init = 1;
22+
+ }
23+
24+
m = Py_InitModule("_imaging", functions);
25+
d = PyModule_GetDict(m);
26+

0 commit comments

Comments
 (0)