Skip to content

Commit bb18da7

Browse files
anderskShaneHarvey
authored andcommitted
PYTHON-2001 Fix Python 3.8 SyntaxWarning: "is not" with a literal (#425)
Fixes this warning from Python 3.8: bson/json_util.py:702: SyntaxWarning: "is not" with a literal. Did you mean "!="? if doc['$minKey'] is not 1: bson/json_util.py:711: SyntaxWarning: "is not" with a literal. Did you mean "!="? if doc['$maxKey'] is not 1:
1 parent 502b598 commit bb18da7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bson/json_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ def _parse_canonical_decimal128(doc):
699699

700700
def _parse_canonical_minkey(doc):
701701
"""Decode a JSON MinKey to bson.min_key.MinKey."""
702-
if doc['$minKey'] is not 1:
702+
if type(doc['$minKey']) is not int or doc['$minKey'] != 1:
703703
raise TypeError('$minKey value must be 1: %s' % (doc,))
704704
if len(doc) != 1:
705705
raise TypeError('Bad $minKey, extra field(s): %s' % (doc,))
@@ -708,7 +708,7 @@ def _parse_canonical_minkey(doc):
708708

709709
def _parse_canonical_maxkey(doc):
710710
"""Decode a JSON MaxKey to bson.max_key.MaxKey."""
711-
if doc['$maxKey'] is not 1:
711+
if type(doc['$maxKey']) is not int or doc['$maxKey'] != 1:
712712
raise TypeError('$maxKey value must be 1: %s', (doc,))
713713
if len(doc) != 1:
714714
raise TypeError('Bad $minKey, extra field(s): %s' % (doc,))

0 commit comments

Comments
 (0)