diff options
author | Mingli Yu <mingli.yu@windriver.com> | 2024-03-18 14:40:35 +0800 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2024-03-27 12:36:58 -0400 |
commit | 283a773f24cedacb45def943a455bc3607f8a7a1 (patch) | |
tree | c5fb62ed7058549f7d196dbe99eab2027a44b3a6 /dynamic-layers/meta-python | |
parent | 2f89aa7e416878a61c5b5fdfd1bc361a28ce8853 (diff) | |
download | meta-security-283a773f24cedacb45def943a455bc3607f8a7a1.tar.gz |
python3-pyinotify: Make asyncore support optional for Python 3
Simple fix for Python 3.12 since it dropped asyncore. Catches the import
error instead of using a version check so that the user can install the
compatibility package for any uses that can't be upgraded to asyncio or
similar immediately.
Fixes:
# python3
Python 3.12.1 (main, Dec 7 2023, 20:45:44) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyinotify
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.12/site-packages/pyinotify.py", line 71, in <module>
import asyncore
ModuleNotFoundError: No module named 'asyncore'
>>>
Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'dynamic-layers/meta-python')
2 files changed, 96 insertions, 0 deletions
diff --git a/dynamic-layers/meta-python/recipes-devtools/python/python3-pyinotify/0001-Make-asyncore-support-optional-for-Python-3.patch b/dynamic-layers/meta-python/recipes-devtools/python/python3-pyinotify/0001-Make-asyncore-support-optional-for-Python-3.patch new file mode 100644 index 0000000..075a035 --- /dev/null +++ b/dynamic-layers/meta-python/recipes-devtools/python/python3-pyinotify/0001-Make-asyncore-support-optional-for-Python-3.patch | |||
@@ -0,0 +1,92 @@ | |||
1 | From 478d595a7d086423733e9f5da5edfe9f1df48682 Mon Sep 17 00:00:00 2001 | ||
2 | From: Troy Curtis Jr <troy@troycurtisjr.com> | ||
3 | Date: Thu, 10 Aug 2023 21:51:15 -0400 | ||
4 | Subject: [PATCH] Make asyncore support optional for Python 3. | ||
5 | |||
6 | Fixes #204. | ||
7 | |||
8 | Upstream-Status: Submitted [https://github.com/seb-m/pyinotify/pull/205] | ||
9 | |||
10 | Signed-off-by: Mingli Yu <mingli.yu@windriver.com> | ||
11 | |||
12 | --- | ||
13 | python3/pyinotify.py | 50 +++++++++++++++++++++++++------------------- | ||
14 | 1 file changed, 28 insertions(+), 22 deletions(-) | ||
15 | |||
16 | diff --git a/python3/pyinotify.py b/python3/pyinotify.py | ||
17 | index bc24313..f4a5a90 100755 | ||
18 | --- a/python3/pyinotify.py | ||
19 | +++ b/python3/pyinotify.py | ||
20 | @@ -68,7 +68,6 @@ from collections import deque | ||
21 | from datetime import datetime, timedelta | ||
22 | import time | ||
23 | import re | ||
24 | -import asyncore | ||
25 | import glob | ||
26 | import locale | ||
27 | import subprocess | ||
28 | @@ -1494,33 +1493,40 @@ class ThreadedNotifier(threading.Thread, Notifier): | ||
29 | self.loop() | ||
30 | |||
31 | |||
32 | -class AsyncNotifier(asyncore.file_dispatcher, Notifier): | ||
33 | - """ | ||
34 | - This notifier inherits from asyncore.file_dispatcher in order to be able to | ||
35 | - use pyinotify along with the asyncore framework. | ||
36 | +try: | ||
37 | + import asyncore | ||
38 | |||
39 | - """ | ||
40 | - def __init__(self, watch_manager, default_proc_fun=None, read_freq=0, | ||
41 | - threshold=0, timeout=None, channel_map=None): | ||
42 | + class AsyncNotifier(asyncore.file_dispatcher, Notifier): | ||
43 | """ | ||
44 | - Initializes the async notifier. The only additional parameter is | ||
45 | - 'channel_map' which is the optional asyncore private map. See | ||
46 | - Notifier class for the meaning of the others parameters. | ||
47 | + This notifier inherits from asyncore.file_dispatcher in order to be able to | ||
48 | + use pyinotify along with the asyncore framework. | ||
49 | |||
50 | """ | ||
51 | - Notifier.__init__(self, watch_manager, default_proc_fun, read_freq, | ||
52 | - threshold, timeout) | ||
53 | - asyncore.file_dispatcher.__init__(self, self._fd, channel_map) | ||
54 | + def __init__(self, watch_manager, default_proc_fun=None, read_freq=0, | ||
55 | + threshold=0, timeout=None, channel_map=None): | ||
56 | + """ | ||
57 | + Initializes the async notifier. The only additional parameter is | ||
58 | + 'channel_map' which is the optional asyncore private map. See | ||
59 | + Notifier class for the meaning of the others parameters. | ||
60 | |||
61 | - def handle_read(self): | ||
62 | - """ | ||
63 | - When asyncore tells us we can read from the fd, we proceed processing | ||
64 | - events. This method can be overridden for handling a notification | ||
65 | - differently. | ||
66 | + """ | ||
67 | + Notifier.__init__(self, watch_manager, default_proc_fun, read_freq, | ||
68 | + threshold, timeout) | ||
69 | + asyncore.file_dispatcher.__init__(self, self._fd, channel_map) | ||
70 | |||
71 | - """ | ||
72 | - self.read_events() | ||
73 | - self.process_events() | ||
74 | + def handle_read(self): | ||
75 | + """ | ||
76 | + When asyncore tells us we can read from the fd, we proceed processing | ||
77 | + events. This method can be overridden for handling a notification | ||
78 | + differently. | ||
79 | + | ||
80 | + """ | ||
81 | + self.read_events() | ||
82 | + self.process_events() | ||
83 | +except ImportError: | ||
84 | + # asyncore was removed in Python 3.12, but try the import instead of a | ||
85 | + # version check in case the compatibility package is installed. | ||
86 | + pass | ||
87 | |||
88 | |||
89 | class TornadoAsyncNotifier(Notifier): | ||
90 | -- | ||
91 | 2.25.1 | ||
92 | |||
diff --git a/dynamic-layers/meta-python/recipes-devtools/python/python3-pyinotify_0.9.6.bb b/dynamic-layers/meta-python/recipes-devtools/python/python3-pyinotify_0.9.6.bb index 9acdf54..ff1b611 100644 --- a/dynamic-layers/meta-python/recipes-devtools/python/python3-pyinotify_0.9.6.bb +++ b/dynamic-layers/meta-python/recipes-devtools/python/python3-pyinotify_0.9.6.bb | |||
@@ -15,4 +15,8 @@ RDEPENDS:${PN} += "\ | |||
15 | SRC_URI[md5sum] = "8e580fa1ff3971f94a6f81672b76c406" | 15 | SRC_URI[md5sum] = "8e580fa1ff3971f94a6f81672b76c406" |
16 | SRC_URI[sha256sum] = "9c998a5d7606ca835065cdabc013ae6c66eb9ea76a00a1e3bc6e0cfe2b4f71f4" | 16 | SRC_URI[sha256sum] = "9c998a5d7606ca835065cdabc013ae6c66eb9ea76a00a1e3bc6e0cfe2b4f71f4" |
17 | 17 | ||
18 | SRC_URI += " \ | ||
19 | file://0001-Make-asyncore-support-optional-for-Python-3.patch \ | ||
20 | " | ||
21 | |||
18 | inherit pypi setuptools3 | 22 | inherit pypi setuptools3 |