summaryrefslogtreecommitdiffstats
path: root/debian/patches/py3.9-fix-collections-import.patch
blob: 7140c8b3e23cd3eba8137247117cc0d430b228ee (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
From: Thomas Goirand <zigo@debian.org>
Date: Wed, 1 Apr 2020 14:08:47 +0200
Subject: Python 3.9: fix collections import

Bug-Debian: https://bugs.debian.org/949018
Forwarded: no
Last-Update: 2020-02-27

As collections has moved to collections.abc, this produces a warning which
may lead to unit testing errors: this is the case when building Rally.

This patch attempts to import from collections.abc, and if it fails, falls
back to collections. This should be harmless.

Note that this patch is probably useless with future version, as hopefully,
upstream will fix it (I didn't check). However, I didn't dare upgrading the
package to the major upstream release 3.x.
---
 src/jinja2/lexer.py   | 5 ++++-
 src/jinja2/nodes.py   | 5 ++++-
 src/jinja2/sandbox.py | 5 ++++-
 src/jinja2/utils.py   | 5 ++++-
 tests/test_utils.py   | 5 ++++-
 5 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/jinja2/lexer.py b/src/jinja2/lexer.py
index aff7e9f..37ef342 100644
--- a/src/jinja2/lexer.py
+++ b/src/jinja2/lexer.py
@@ -6,7 +6,10 @@ template code and python code in expressions.
 import re
 import typing as t
 from ast import literal_eval
-from collections import deque
+try:
+    from collections.abc import deque
+except ImportError:
+    from collections import deque
 from sys import intern
 
 from ._identifier import pattern as name_re
diff --git a/src/jinja2/nodes.py b/src/jinja2/nodes.py
index b2f88d9..53da1e9 100644
--- a/src/jinja2/nodes.py
+++ b/src/jinja2/nodes.py
@@ -5,7 +5,10 @@ to normalize nodes.
 import inspect
 import operator
 import typing as t
-from collections import deque
+try:
+    from collections.abc import deque
+except ImportError:
+    from collections import deque
 
 from markupsafe import Markup
 
diff --git a/src/jinja2/sandbox.py b/src/jinja2/sandbox.py
index 06d7414..f443c18 100644
--- a/src/jinja2/sandbox.py
+++ b/src/jinja2/sandbox.py
@@ -6,7 +6,10 @@ import types
 import typing as t
 from _string import formatter_field_name_split  # type: ignore
 from collections import abc
-from collections import deque
+try:
+    from collections.abc import deque
+except ImportError:
+    from collections import deque
 from string import Formatter
 
 from markupsafe import EscapeFormatter
diff --git a/src/jinja2/utils.py b/src/jinja2/utils.py
index 9b5f5a5..205b2af 100644
--- a/src/jinja2/utils.py
+++ b/src/jinja2/utils.py
@@ -4,7 +4,10 @@ import os
 import re
 import typing as t
 from collections import abc
-from collections import deque
+try:
+    from collections.abc import deque
+except ImportError:
+    from collections import deque
 from random import choice
 from random import randrange
 from threading import Lock
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 7b58af1..9013d7c 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -1,6 +1,9 @@
 import pickle
 import random
-from collections import deque
+try:
+    from collections.abc import deque
+except ImportError:
+    from collections import deque
 from copy import copy as shallow_copy
 
 import pytest