mirror of
https://git.yoctoproject.org/meta-security
synced 2026-01-12 03:10:13 +00:00
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>
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
From 478d595a7d086423733e9f5da5edfe9f1df48682 Mon Sep 17 00:00:00 2001
|
||||
From: Troy Curtis Jr <troy@troycurtisjr.com>
|
||||
Date: Thu, 10 Aug 2023 21:51:15 -0400
|
||||
Subject: [PATCH] Make asyncore support optional for Python 3.
|
||||
|
||||
Fixes #204.
|
||||
|
||||
Upstream-Status: Submitted [https://github.com/seb-m/pyinotify/pull/205]
|
||||
|
||||
Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
|
||||
|
||||
---
|
||||
python3/pyinotify.py | 50 +++++++++++++++++++++++++-------------------
|
||||
1 file changed, 28 insertions(+), 22 deletions(-)
|
||||
|
||||
diff --git a/python3/pyinotify.py b/python3/pyinotify.py
|
||||
index bc24313..f4a5a90 100755
|
||||
--- a/python3/pyinotify.py
|
||||
+++ b/python3/pyinotify.py
|
||||
@@ -68,7 +68,6 @@ from collections import deque
|
||||
from datetime import datetime, timedelta
|
||||
import time
|
||||
import re
|
||||
-import asyncore
|
||||
import glob
|
||||
import locale
|
||||
import subprocess
|
||||
@@ -1494,33 +1493,40 @@ class ThreadedNotifier(threading.Thread, Notifier):
|
||||
self.loop()
|
||||
|
||||
|
||||
-class AsyncNotifier(asyncore.file_dispatcher, Notifier):
|
||||
- """
|
||||
- This notifier inherits from asyncore.file_dispatcher in order to be able to
|
||||
- use pyinotify along with the asyncore framework.
|
||||
+try:
|
||||
+ import asyncore
|
||||
|
||||
- """
|
||||
- def __init__(self, watch_manager, default_proc_fun=None, read_freq=0,
|
||||
- threshold=0, timeout=None, channel_map=None):
|
||||
+ class AsyncNotifier(asyncore.file_dispatcher, Notifier):
|
||||
"""
|
||||
- Initializes the async notifier. The only additional parameter is
|
||||
- 'channel_map' which is the optional asyncore private map. See
|
||||
- Notifier class for the meaning of the others parameters.
|
||||
+ This notifier inherits from asyncore.file_dispatcher in order to be able to
|
||||
+ use pyinotify along with the asyncore framework.
|
||||
|
||||
"""
|
||||
- Notifier.__init__(self, watch_manager, default_proc_fun, read_freq,
|
||||
- threshold, timeout)
|
||||
- asyncore.file_dispatcher.__init__(self, self._fd, channel_map)
|
||||
+ def __init__(self, watch_manager, default_proc_fun=None, read_freq=0,
|
||||
+ threshold=0, timeout=None, channel_map=None):
|
||||
+ """
|
||||
+ Initializes the async notifier. The only additional parameter is
|
||||
+ 'channel_map' which is the optional asyncore private map. See
|
||||
+ Notifier class for the meaning of the others parameters.
|
||||
|
||||
- def handle_read(self):
|
||||
- """
|
||||
- When asyncore tells us we can read from the fd, we proceed processing
|
||||
- events. This method can be overridden for handling a notification
|
||||
- differently.
|
||||
+ """
|
||||
+ Notifier.__init__(self, watch_manager, default_proc_fun, read_freq,
|
||||
+ threshold, timeout)
|
||||
+ asyncore.file_dispatcher.__init__(self, self._fd, channel_map)
|
||||
|
||||
- """
|
||||
- self.read_events()
|
||||
- self.process_events()
|
||||
+ def handle_read(self):
|
||||
+ """
|
||||
+ When asyncore tells us we can read from the fd, we proceed processing
|
||||
+ events. This method can be overridden for handling a notification
|
||||
+ differently.
|
||||
+
|
||||
+ """
|
||||
+ self.read_events()
|
||||
+ self.process_events()
|
||||
+except ImportError:
|
||||
+ # asyncore was removed in Python 3.12, but try the import instead of a
|
||||
+ # version check in case the compatibility package is installed.
|
||||
+ pass
|
||||
|
||||
|
||||
class TornadoAsyncNotifier(Notifier):
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@@ -15,4 +15,8 @@ RDEPENDS:${PN} += "\
|
||||
SRC_URI[md5sum] = "8e580fa1ff3971f94a6f81672b76c406"
|
||||
SRC_URI[sha256sum] = "9c998a5d7606ca835065cdabc013ae6c66eb9ea76a00a1e3bc6e0cfe2b4f71f4"
|
||||
|
||||
SRC_URI += " \
|
||||
file://0001-Make-asyncore-support-optional-for-Python-3.patch \
|
||||
"
|
||||
|
||||
inherit pypi setuptools3
|
||||
|
||||
Reference in New Issue
Block a user