Skip to content

Commit 4a80a8f

Browse files
committed
Fix deprecated import collections
Replace import collections to import collection.abc for Python >= 3.3 See issue #252
1 parent ecf1dd6 commit 4a80a8f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

rethinkdb/ast.py

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

2121
import base64
2222
import binascii
23-
import collections
23+
import sys
24+
25+
if sys.version_info.major * 10 + sys.version_info.minor < 33:
26+
# python < 3.3 uses collections
27+
import collections
28+
else:
29+
# but collections is deprecated from python >= 3.3
30+
import collections.abc as collections
31+
2432
import datetime
2533
import json
2634
import threading
2735

2836
from rethinkdb import ql2_pb2
29-
from rethinkdb.errors import QueryPrinter, ReqlDriverCompileError, ReqlDriverError, T
37+
from rethinkdb.errors import (QueryPrinter, ReqlDriverCompileError,
38+
ReqlDriverError, T)
3039

3140
P_TERM = ql2_pb2.Term.TermType
3241

@@ -74,7 +83,7 @@ def clear(cls):
7483

7584
def expr(val, nesting_depth=20):
7685
"""
77-
Convert a Python primitive into a RQL primitive value
86+
Convert a Python primitive into a RQL primitive value
7887
"""
7988
if not isinstance(nesting_depth, int):
8089
raise ReqlDriverCompileError("Second argument to `r.expr` must be a number.")
@@ -759,7 +768,7 @@ def recursively_make_hashable(obj):
759768

760769
class ReQLEncoder(json.JSONEncoder):
761770
"""
762-
Default JSONEncoder subclass to handle query conversion.
771+
Default JSONEncoder subclass to handle query conversion.
763772
"""
764773

765774
def __init__(self):
@@ -779,7 +788,7 @@ def default(self, obj):
779788

780789
class ReQLDecoder(json.JSONDecoder):
781790
"""
782-
Default JSONDecoder subclass to handle pseudo-type conversion.
791+
Default JSONDecoder subclass to handle pseudo-type conversion.
783792
"""
784793

785794
def __init__(self, reql_format_opts=None):

0 commit comments

Comments
 (0)