aboutsummaryrefslogtreecommitdiff
path: root/lang/python/python-stem/patches/001-fixes-for-Python310.patch
blob: d7a5f6c2bee09302aa62160f565cb9a83b1b5954 (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
From 36bcb170ba9097885902513640075eac2e6ce384 Mon Sep 17 00:00:00 2001
From: Calin Culianu <calin.culianu@gmail.com>
Date: Mon, 8 Nov 2021 18:15:59 -0600
Subject: [PATCH] Fixup for Python 3.10

Closes issue #109.  Long story short: a few names from collection are
now moved to collection.abc exclusively starting in Python 3.10. The
only name this app uses from there that was moved is
`collections.Iterable`.  Python versions starting from 3.3 support both
`collections.Iterable` and `collections.abc.Iterable` as the way to refer to
this class, which Python 3.10 being the first one to drop
`collections.Iterable`.  So.. we just work around this API quirk
and always refer ot it as `collections.abc.Iterable`.
---
 stem/control.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/stem/control.py
+++ b/stem/control.py
@@ -249,6 +249,7 @@ If you're fine with allowing your script
 
 import calendar
 import collections
+import collections.abc
 import functools
 import inspect
 import io
@@ -2532,7 +2533,7 @@ class Controller(BaseController):
     for param, value in params:
       if isinstance(value, str):
         query_comp.append('%s="%s"' % (param, value.strip()))
-      elif isinstance(value, collections.Iterable):
+      elif isinstance(value, collections.abc.Iterable):
         query_comp.extend(['%s="%s"' % (param, val.strip()) for val in value])
       elif not value:
         query_comp.append(param)