Skip to content
Snippets Groups Projects
Commit 5b5258dc authored by Stefano Rivera's avatar Stefano Rivera
Browse files

Patches to add Python 3.10 support: (Closes: #1009243)

* Patches to add Python 3.10 support: (Closes: #1009243)
  - 11_py310_py_ssize_t_clean.patch
  - 12_py310_collections_import.patch
parent c06256a1
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,9 @@ libapache2-mod-python (3.5.0+git20211031.e6458ec-1) UNRELEASED; urgency=medium
* Drop patches, superseded upstream: 04_html-escape.patch,
05_fix_spelling.patch, 07_fix-compilation-with-python-3.7.patch,
09_create-DESTDIR-BINDIR-if-needed.patch.
* Patches to add Python 3.10 support: (Closes: #1009243)
- 11_py310_py_ssize_t_clean.patch
- 12_py310_collections_import.patch
-- Stefano Rivera <stefanor@debian.org> Sun, 17 Apr 2022 19:12:13 -0400
......
From: Andreas Hasenack <andreas.hasenack@ubuntu.com>
Date: Sun, 17 Apr 2022 19:30:27 -0400
Subject: Make mod-python PY_SSIZE_T_CLEAN
Required for Python 3.10 support.
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
---
src/connobject.c | 2 +-
src/filterobject.c | 2 +-
src/include/mod_python.h | 1 +
src/include/mod_python.h.in | 1 +
src/requestobject.c | 2 +-
5 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/connobject.c b/src/connobject.c
index 6f029a4..82cf195 100644
--- a/src/connobject.c
+++ b/src/connobject.c
@@ -232,7 +232,7 @@ static PyObject * conn_readline(connobject *self, PyObject *args)
static PyObject * conn_write(connobject *self, PyObject *args)
{
char *buff;
- int len;
+ Py_ssize_t len;
apr_bucket_brigade *bb;
apr_bucket *b;
PyObject *s;
diff --git a/src/filterobject.c b/src/filterobject.c
index 966d2f8..712dbb4 100644
--- a/src/filterobject.c
+++ b/src/filterobject.c
@@ -315,7 +315,7 @@ static PyObject *filter_write(filterobject *self, PyObject *args)
{
char *buff;
- int len;
+ Py_ssize_t len;
apr_bucket *b;
PyObject *s;
conn_rec *c = self->request_obj->request_rec->connection;
diff --git a/src/include/mod_python.h b/src/include/mod_python.h
index 68a77d4..69f0214 100644
--- a/src/include/mod_python.h
+++ b/src/include/mod_python.h
@@ -43,6 +43,7 @@
*/
/* Python headers */
+#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
diff --git a/src/include/mod_python.h.in b/src/include/mod_python.h.in
index 7d536c5..8d97c47 100644
--- a/src/include/mod_python.h.in
+++ b/src/include/mod_python.h.in
@@ -43,6 +43,7 @@
*/
/* Python headers */
+#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
diff --git a/src/requestobject.c b/src/requestobject.c
index 65d42ac..38b7165 100644
--- a/src/requestobject.c
+++ b/src/requestobject.c
@@ -1576,7 +1576,7 @@ static PyObject * req_update_mtime(requestobject *self, PyObject *args)
static PyObject * req_write(requestobject *self, PyObject *args)
{
- int len;
+ Py_ssize_t len;
int rc;
char *buff;
int flush=1;
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()
......@@ -2,3 +2,5 @@
02_makefile.patch
03_ignore-git-version.patch
10_make-package-reproducible.patch
11_py310_py_ssize_t_clean.patch
12_py310_collections_import.patch
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment