1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
From: Andreas Hasenack <andreas.hasenack@ubuntu.com>
Date: Sun, 17 Apr 2022 19:31:55 -0400
Subject: Python 3.10 support: import Callable from collections.abc
Bug-Debian: https://bugs.debian.org/1009243
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libapache2-mod-python/+bug/1960088
Forwarded: https://github.com/grisha/mod_python/pull/114
---
lib/python/mod_python/publisher.py | 4 ++--
lib/python/mod_python/util.py | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/python/mod_python/publisher.py b/lib/python/mod_python/publisher.py
index 75d103f..5882e77 100644
--- a/lib/python/mod_python/publisher.py
+++ b/lib/python/mod_python/publisher.py
@@ -51,8 +51,8 @@ def _callable(obj):
if PY2:
return callable(obj)
else:
- return (isinstance(obj, collections.Callable) or
- (hasattr(obj, "__call__") and isinstance(obj.__call__, collections.Callable)))
+ return (isinstance(obj, collections.abc.Callable) or
+ (hasattr(obj, "__call__") and isinstance(obj.__call__, collections.abc.Callable)))
####################### The published page cache ##############################
diff --git a/lib/python/mod_python/util.py b/lib/python/mod_python/util.py
index 67d6b3f..30601a5 100644
--- a/lib/python/mod_python/util.py
+++ b/lib/python/mod_python/util.py
@@ -368,12 +368,12 @@ class FieldStorage:
filename = None
if b"filename" in disp_options:
filename = disp_options[b"filename"]
- if file_callback and isinstance(file_callback, collections.Callable):
+ if file_callback and isinstance(file_callback, collections.abc.Callable):
file = file_callback(filename)
else:
file = tempfile.TemporaryFile("w+b")
else:
- if field_callback and isinstance(field_callback, collections.Callable):
+ if field_callback and isinstance(field_callback, collections.abc.Callable):
file = field_callback()
else:
file = BytesIO()
|