Skip to content

Commit 424cff7

Browse files
authored
Fix deprecated import collections (#253)
Replace import collections to import collection.abc for Python >= 3.3 See issue #252
1 parent ecf1dd6 commit 424cff7

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

rethinkdb/ast.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,21 @@
2020

2121
import base64
2222
import binascii
23-
import collections
2423
import datetime
2524
import json
25+
import sys
2626
import threading
2727

2828
from rethinkdb import ql2_pb2
29-
from rethinkdb.errors import QueryPrinter, ReqlDriverCompileError, ReqlDriverError, T
29+
from rethinkdb.errors import (QueryPrinter, ReqlDriverCompileError,
30+
ReqlDriverError, T)
31+
32+
if sys.version_info < (3, 3):
33+
# python < 3.3 uses collections
34+
import collections
35+
else:
36+
# but collections is deprecated from python >= 3.3
37+
import collections.abc as collections
3038

3139
P_TERM = ql2_pb2.Term.TermType
3240

@@ -74,7 +82,7 @@ def clear(cls):
7482

7583
def expr(val, nesting_depth=20):
7684
"""
77-
Convert a Python primitive into a RQL primitive value
85+
Convert a Python primitive into a RQL primitive value
7886
"""
7987
if not isinstance(nesting_depth, int):
8088
raise ReqlDriverCompileError("Second argument to `r.expr` must be a number.")
@@ -759,7 +767,7 @@ def recursively_make_hashable(obj):
759767

760768
class ReQLEncoder(json.JSONEncoder):
761769
"""
762-
Default JSONEncoder subclass to handle query conversion.
770+
Default JSONEncoder subclass to handle query conversion.
763771
"""
764772

765773
def __init__(self):
@@ -779,7 +787,7 @@ def default(self, obj):
779787

780788
class ReQLDecoder(json.JSONDecoder):
781789
"""
782-
Default JSONDecoder subclass to handle pseudo-type conversion.
790+
Default JSONDecoder subclass to handle pseudo-type conversion.
783791
"""
784792

785793
def __init__(self, reql_format_opts=None):

0 commit comments

Comments
 (0)