summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham Dumpleton <Graham.Dumpleton@gmail.com>2022-05-02 10:44:04 +1000
committerGraham Dumpleton <Graham.Dumpleton@gmail.com>2022-05-02 10:44:04 +1000
commit2a3701e49a1fcc08946e9cb2fcd5c7f8ae6e2b85 (patch)
tree39bfc08e3356608b7b11425cca5f496823cbd70a
parent56bde85a5958ae60708142f706261da9dc54e296 (diff)
downloadmod_wsgi-2a3701e49a1fcc08946e9cb2fcd5c7f8ae6e2b85.tar.gz
Updates so compiles on Python 3.11.
-rw-r--r--.github/workflows/main.yml2
-rw-r--r--docs/release-notes/version-4.9.1.rst3
-rw-r--r--src/server/mod_wsgi.c17
3 files changed, 21 insertions, 1 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index e04b916..c38e733 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -34,7 +34,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10"]
+ python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11-dev"]
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
diff --git a/docs/release-notes/version-4.9.1.rst b/docs/release-notes/version-4.9.1.rst
index 6790ac5..b6731ff 100644
--- a/docs/release-notes/version-4.9.1.rst
+++ b/docs/release-notes/version-4.9.1.rst
@@ -19,6 +19,9 @@ Bugs Fixed
mean that a window size change event will again cause Apache to shutdown in
these cases though.
+* Update code so compiles on Python 3.11. Python 3.11 makes structures for
+ Python frame objects opaque and requires functions to access struct members.
+
Features Changed
----------------
diff --git a/src/server/mod_wsgi.c b/src/server/mod_wsgi.c
index f537d44..00ae607 100644
--- a/src/server/mod_wsgi.c
+++ b/src/server/mod_wsgi.c
@@ -9548,6 +9548,9 @@ static void wsgi_log_stack_traces(void)
const char *filename = NULL;
const char *name = NULL;
+#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 9)
+ lineno = PyFrame_GetLineNumber(current);
+#else
if (current->f_trace) {
lineno = current->f_lineno;
}
@@ -9555,10 +9558,16 @@ static void wsgi_log_stack_traces(void)
lineno = PyCode_Addr2Line(current->f_code,
current->f_lasti);
}
+#endif
#if PY_MAJOR_VERSION >= 3
+#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 9)
+ filename = PyUnicode_AsUTF8(PyFrame_GetCode(current)->co_filename);
+ name = PyUnicode_AsUTF8(PyFrame_GetCode(current)->co_name);
+#else
filename = PyUnicode_AsUTF8(current->f_code->co_filename);
name = PyUnicode_AsUTF8(current->f_code->co_name);
+#endif
#else
filename = PyString_AsString(current->f_code->co_filename);
name = PyString_AsString(current->f_code->co_name);
@@ -9571,7 +9580,11 @@ static void wsgi_log_stack_traces(void)
getpid(), thread_id, filename, lineno, name);
}
else {
+#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 9)
+ if (PyFrame_GetBack(current)) {
+#else
if (current->f_back) {
+#endif
ap_log_error(APLOG_MARK, APLOG_INFO, 0, wsgi_server,
"mod_wsgi (pid=%d): called from file "
"\"%s\", line %d, in %s,", getpid(),
@@ -9585,7 +9598,11 @@ static void wsgi_log_stack_traces(void)
}
}
+#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 9)
+ current = PyFrame_GetBack(current);
+#else
current = current->f_back;
+#endif
}
}
}