Skip to content

Commit 3737c09

Browse files
authored
Upgrades python-cheetah to version 3.2.6.post1 (#12381)
1 parent 24e667a commit 3737c09

9 files changed

Lines changed: 357 additions & 73 deletions
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
diff -ur cheetah3-3.2.6.post1.orig/Cheetah/NameMapper.py cheetah3-3.2.6.post1/Cheetah/NameMapper.py
2+
--- cheetah3-3.2.6.post1.orig/Cheetah/NameMapper.py 2024-10-30 14:53:31.879049340 -0700
3+
+++ cheetah3-3.2.6.post1/Cheetah/NameMapper.py 2024-10-30 14:54:48.896711953 -0700
4+
@@ -140,6 +140,7 @@
5+
"""
6+
7+
import inspect
8+
+import sys
9+
from pprint import pformat
10+
11+
from Cheetah.compat import PY2
12+
@@ -147,6 +148,8 @@
13+
from collections import Mapping
14+
else:
15+
from collections.abc import Mapping
16+
+ if sys.version_info[:2] >= (3, 13):
17+
+ from collections.abc import MutableMapping
18+
19+
_INCLUDE_NAMESPACE_REPR_IN_NOTFOUND_EXCEPTIONS = False
20+
_ALLOW_WRAPPING_OF_NOTFOUND_EXCEPTIONS = True
21+
@@ -315,6 +318,10 @@
22+
try:
23+
if not frame:
24+
frame = inspect.stack()[1][0]
25+
+ if sys.version_info[:2] >= (3, 13):
26+
+ FrameLocalsProxy = frame.f_locals
27+
+ if not isinstance(FrameLocalsProxy, Mapping):
28+
+ MutableMapping.register(type(FrameLocalsProxy))
29+
key = name.split('.')[0]
30+
for namespace in _namespaces(frame, searchList):
31+
if hasKey(namespace, key):
32+
diff -ur cheetah3-3.2.6.post1.orig/docs/news.rst cheetah3-3.2.6.post1/docs/news.rst
33+
--- cheetah3-3.2.6.post1.orig/docs/news.rst 2024-10-30 14:53:31.872049370 -0700
34+
+++ cheetah3-3.2.6.post1/docs/news.rst 2024-10-30 14:54:36.807764910 -0700
35+
@@ -11,6 +11,8 @@
36+
- Fixed ``_namemapper.c``: Silent an inadvertent ``TypeError`` exception
37+
in ``PyMapping_HasKeyString`` under Python 3.13+
38+
caused by ``_namemapper`` looking up a key in a non-dictionary.
39+
+ - Fixed mapping test in ``NameMapper.py``:
40+
+ Python 3.13 brough a new mapping type ``FrameLocalsProxy``.
41+
42+
3.2.6.post1 (2021-02-22)
43+
------------------------
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
diff -ur cheetah3-3.2.6.post1.orig/Cheetah/Tests/Test.py cheetah3-3.2.6.post1/Cheetah/Tests/Test.py
2+
--- cheetah3-3.2.6.post1.orig/Cheetah/Tests/Test.py 2024-10-30 07:25:43.621206329 -0700
3+
+++ cheetah3-3.2.6.post1/Cheetah/Tests/Test.py 2024-10-30 09:48:51.480330619 -0700
4+
@@ -31,23 +31,24 @@
5+
SyntaxAndOutput.install_eols()
6+
7+
suites = [
8+
- unittest.findTestCases(Analyzer),
9+
- unittest.findTestCases(Filters),
10+
- unittest.findTestCases(ImportHooks),
11+
- unittest.findTestCases(LoadTemplate),
12+
- unittest.findTestCases(Misc),
13+
- unittest.findTestCases(NameMapper),
14+
- unittest.findTestCases(Parser),
15+
- unittest.findTestCases(Regressions),
16+
- unittest.findTestCases(SyntaxAndOutput),
17+
- unittest.findTestCases(Template),
18+
- unittest.findTestCases(TemplateCmdLineIface),
19+
- unittest.findTestCases(Unicode),
20+
- unittest.findTestCases(NameMapper_pure),
21+
+ unittest.defaultTestLoader.loadTestsFromModule(Analyzer),
22+
+ unittest.defaultTestLoader.loadTestsFromModule(Filters),
23+
+ unittest.defaultTestLoader.loadTestsFromModule(ImportHooks),
24+
+ unittest.defaultTestLoader.loadTestsFromModule(LoadTemplate),
25+
+ unittest.defaultTestLoader.loadTestsFromModule(Misc),
26+
+ unittest.defaultTestLoader.loadTestsFromModule(NameMapper),
27+
+ unittest.defaultTestLoader.loadTestsFromModule(Parser),
28+
+ unittest.defaultTestLoader.loadTestsFromModule(Regressions),
29+
+ unittest.defaultTestLoader.loadTestsFromModule(SyntaxAndOutput),
30+
+ unittest.defaultTestLoader.loadTestsFromModule(Template),
31+
+ unittest.defaultTestLoader.loadTestsFromModule(TemplateCmdLineIface),
32+
+ unittest.defaultTestLoader.loadTestsFromModule(Unicode),
33+
+ unittest.defaultTestLoader.loadTestsFromModule(NameMapper_pure),
34+
]
35+
36+
if not sys.platform.startswith('java'):
37+
- suites.append(unittest.findTestCases(CheetahWrapper))
38+
+ suites.append(
39+
+ unittest.defaultTestLoader.loadTestsFromModule(CheetahWrapper))
40+
41+
if __name__ == '__main__':
42+
if 'xml' in sys.argv:
43+
Only in cheetah3-3.2.6.post1/Cheetah/Tests: Test.py.orig
44+
diff -ur cheetah3-3.2.6.post1.orig/docs/news.rst cheetah3-3.2.6.post1/docs/news.rst
45+
--- cheetah3-3.2.6.post1.orig/docs/news.rst 2024-10-30 07:37:07.891109768 -0700
46+
+++ cheetah3-3.2.6.post1/docs/news.rst 2024-10-30 09:50:52.787837501 -0700
47+
@@ -6,6 +6,8 @@
48+
2024-10-30:
49+
50+
- Protect ``import cgi`` in preparation to Python 3.13.
51+
+ - Fix DeprecationWarning: ``unittest.findTestCases()`` is deprecated. Use
52+
+ ``unittest.TestLoader.loadTestsFromModule()`` instead.
53+
54+
3.2.6.post1 (2021-02-22)
55+
------------------------
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
diff -ur cheetah3-3.2.6.post1.orig/Cheetah/Template.py cheetah3-3.2.6.post1/Cheetah/Template.py
2+
--- cheetah3-3.2.6.post1.orig/Cheetah/Template.py 2024-10-30 22:02:27.084580240 -0700
3+
+++ cheetah3-3.2.6.post1/Cheetah/Template.py 2024-10-30 22:06:23.575516652 -0700
4+
@@ -24,6 +24,7 @@
5+
try:
6+
import cgi # Used by .webInput() if the template is a CGI script.
7+
except ImportError: # Python 3.13+
8+
+ from urllib.parse import parse_qs
9+
cgi = None
10+
import types
11+
12+
@@ -1919,11 +1920,17 @@
13+
"""
14+
src = src.lower()
15+
isCgi = not self._CHEETAH__isControlledByWebKit
16+
- if isCgi and (cgi is not None) and src in ('f', 'v'):
17+
+ if isCgi and src in ('f', 'v'):
18+
global _formUsedByWebInput
19+
- if _formUsedByWebInput is None:
20+
- _formUsedByWebInput = cgi.FieldStorage()
21+
- source, func = 'field', _formUsedByWebInput.getvalue
22+
+ if cgi is None:
23+
+ if _formUsedByWebInput is None:
24+
+ _formUsedByWebInput = \
25+
+ parse_qs(os.environ.get('QUERY_STRING', ''))
26+
+ source, func = 'field', _formUsedByWebInput.get
27+
+ else:
28+
+ if _formUsedByWebInput is None:
29+
+ _formUsedByWebInput = cgi.FieldStorage()
30+
+ source, func = 'field', _formUsedByWebInput.getvalue
31+
elif isCgi and src == 'c':
32+
raise RuntimeError("can't get cookies from a CGI script")
33+
elif isCgi and src == 's':
34+
diff -ur cheetah3-3.2.6.post1.orig/docs/news.rst cheetah3-3.2.6.post1/docs/news.rst
35+
--- cheetah3-3.2.6.post1.orig/docs/news.rst 2024-10-30 22:02:27.064580330 -0700
36+
+++ cheetah3-3.2.6.post1/docs/news.rst 2024-10-30 22:07:00.025352723 -0700
37+
@@ -13,6 +13,8 @@
38+
caused by ``_namemapper`` looking up a key in a non-dictionary.
39+
- Fixed mapping test in ``NameMapper.py``:
40+
Python 3.13 brough a new mapping type ``FrameLocalsProxy``.
41+
+ - Fixed ``Template.webInput``: Use ``urllib.parse.parse_qs``
42+
+ instead of ``cgi.FieldStorage``; Python 3.13 dropped ``cgi``.
43+
44+
3.2.6.post1 (2021-02-22)
45+
------------------------
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
diff -ur cheetah3-3.2.6.post1.orig/Cheetah/Template.py cheetah3-3.2.6.post1/Cheetah/Template.py
2+
--- cheetah3-3.2.6.post1.orig/Cheetah/Template.py 2024-10-30 07:25:43.621206329 -0700
3+
+++ cheetah3-3.2.6.post1/Cheetah/Template.py 2024-10-30 07:28:32.723440631 -0700
4+
@@ -21,7 +21,10 @@
5+
from io import StringIO
6+
import traceback
7+
import pprint
8+
-import cgi # Used by .webInput() if the template is a CGI script.
9+
+try:
10+
+ import cgi # Used by .webInput() if the template is a CGI script.
11+
+except ImportError: # Python 3.13+
12+
+ cgi = None
13+
import types
14+
15+
from Cheetah import ErrorCatchers # for placeholder tags
16+
@@ -1916,7 +1919,7 @@
17+
"""
18+
src = src.lower()
19+
isCgi = not self._CHEETAH__isControlledByWebKit
20+
- if isCgi and src in ('f', 'v'):
21+
+ if isCgi and (cgi is not None) and src in ('f', 'v'):
22+
global _formUsedByWebInput
23+
if _formUsedByWebInput is None:
24+
_formUsedByWebInput = cgi.FieldStorage()
25+
diff -ur cheetah3-3.2.6.post1.orig/docs/news.rst cheetah3-3.2.6.post1/docs/news.rst
26+
--- cheetah3-3.2.6.post1.orig/docs/news.rst 2021-02-22 02:22:54.000000000 -0800
27+
+++ cheetah3-3.2.6.post1/docs/news.rst 2024-10-30 07:37:07.891109768 -0700
28+
@@ -1,6 +1,12 @@
29+
News
30+
====
31+
32+
+Backports
33+
+---------
34+
+2024-10-30:
35+
+
36+
+ - Protect ``import cgi`` in preparation to Python 3.13.
37+
+
38+
3.2.6.post1 (2021-02-22)
39+
------------------------
40+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
diff -ur cheetah3-3.2.6.post1.orig/Cheetah/c/_namemapper.c cheetah3-3.2.6.post1/Cheetah/c/_namemapper.c
2+
--- cheetah3-3.2.6.post1.orig/Cheetah/c/_namemapper.c 2021-02-22 02:22:54.000000000 -0800
3+
+++ cheetah3-3.2.6.post1/Cheetah/c/_namemapper.c 2024-10-30 12:41:44.371896758 -0700
4+
@@ -179,11 +179,26 @@
5+
return NULL;
6+
}
7+
8+
+ #if PY_VERSION_HEX >= 0x030d0000
9+
+ /* Python 3.13+: this is to silent error from PyMapping_HasKeyString */
10+
+ if (PyMapping_Check(currentVal) && PyMapping_GetOptionalItemString(currentVal, currentKey, &nextVal)
11+
+ && (!PyErr_Occurred())
12+
+ ) {
13+
+ #else
14+
if (PyMapping_Check(currentVal) && PyMapping_HasKeyString(currentVal, currentKey)) {
15+
nextVal = PyMapping_GetItemString(currentVal, currentKey);
16+
- }
17+
+ #endif
18+
19+
- else {
20+
+ } else {
21+
+ #if PY_VERSION_HEX >= 0x030d0000
22+
+ if ((PyErr_Occurred() != NULL) &&
23+
+ (PyErr_ExceptionMatches(PyExc_TypeError))) {
24+
+ /* Python 3.13+ don't like testing 'str1'['str2'].
25+
+ The error must be silenced to continue testing
26+
+ getattr('str1', 'str2'). */
27+
+ PyErr_Clear();
28+
+ }
29+
+ #endif
30+
PyObject *exc;
31+
nextVal = PyObject_GetAttrString(currentVal, currentKey);
32+
exc = PyErr_Occurred();
33+
diff -ur cheetah3-3.2.6.post1.orig/docs/news.rst cheetah3-3.2.6.post1/docs/news.rst
34+
--- cheetah3-3.2.6.post1.orig/docs/news.rst 2024-10-30 09:54:36.896932574 -0700
35+
+++ cheetah3-3.2.6.post1/docs/news.rst 2024-10-30 12:42:50.772613341 -0700
36+
@@ -8,6 +8,9 @@
37+
- Protect ``import cgi`` in preparation to Python 3.13.
38+
- Fix DeprecationWarning: ``unittest.findTestCases()`` is deprecated. Use
39+
``unittest.TestLoader.loadTestsFromModule()`` instead.
40+
+ - Fixed ``_namemapper.c``: Silent an inadvertent ``TypeError`` exception
41+
+ in ``PyMapping_HasKeyString`` under Python 3.13+
42+
+ caused by ``_namemapper`` looking up a key in a non-dictionary.
43+
44+
3.2.6.post1 (2021-02-22)
45+
------------------------
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"Signatures": {
3-
"python-cheetah-3.2.4.tar.gz": "32780a2729b7acf1ab4df9b9325b33e4a1aaf7dcae8c2c66e6e83c70499db863"
3+
"python-cheetah-3.2.6.post1.tar.gz": "ef923bd4feca0cb17e8dc5f726a41a07d8bab26a15246630f206e9b6401ce4b6"
44
}
55
}

0 commit comments

Comments
 (0)