From 71112d0eddf6b26f021053959c186aa3ed1df1aa Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Mon, 1 Mar 2021 23:51:34 +0100 Subject: [PATCH] Fix deprecated import collections Replace import collections to import collection.abc for Python >= 3.3 See issue #252 --- rethinkdb/ast.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/rethinkdb/ast.py b/rethinkdb/ast.py index 3b9fddc6..01640371 100644 --- a/rethinkdb/ast.py +++ b/rethinkdb/ast.py @@ -20,13 +20,22 @@ import base64 import binascii -import collections +import sys + +if sys.version_info < (3, 3): + # python < 3.3 uses collections + import collections +else: + # but collections is deprecated from python >= 3.3 + import collections.abc as collections + import datetime import json import threading from rethinkdb import ql2_pb2 -from rethinkdb.errors import QueryPrinter, ReqlDriverCompileError, ReqlDriverError, T +from rethinkdb.errors import (QueryPrinter, ReqlDriverCompileError, + ReqlDriverError, T) P_TERM = ql2_pb2.Term.TermType @@ -74,7 +83,7 @@ def clear(cls): def expr(val, nesting_depth=20): """ - Convert a Python primitive into a RQL primitive value + Convert a Python primitive into a RQL primitive value """ if not isinstance(nesting_depth, int): raise ReqlDriverCompileError("Second argument to `r.expr` must be a number.") @@ -759,7 +768,7 @@ def recursively_make_hashable(obj): class ReQLEncoder(json.JSONEncoder): """ - Default JSONEncoder subclass to handle query conversion. + Default JSONEncoder subclass to handle query conversion. """ def __init__(self): @@ -779,7 +788,7 @@ def default(self, obj): class ReQLDecoder(json.JSONDecoder): """ - Default JSONDecoder subclass to handle pseudo-type conversion. + Default JSONDecoder subclass to handle pseudo-type conversion. """ def __init__(self, reql_format_opts=None):