Skip to content

SyntaxWarning: "is" with a literal. Did you mean "=="?

Python 3.8 adds a new SyntaxWarning if is or is not is used where == or != is correct. It's generated only when createding the pyc file, so typically you'll only ever see the error once. (This is a good overview of why is/is not can cause bugs.) Glance generates these warnings in a variety of places:

$ # Ensure the warnings are generated
$ rm -rf pyglance/glance/__pycache__
$ glance
/data/users/adesmet/glance-testing/glance/pyglance/glance/compare.py:558: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif   (len(aData.shape) is 1) :
/data/users/adesmet/glance-testing/glance/pyglance/glance/compare.py:562: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif (len(aData.shape) is 2) :
/data/users/adesmet/glance-testing/glance/pyglance/glance/compare.py:912: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif   (len(aData.shape) is 1) :
/data/users/adesmet/glance-testing/glance/pyglance/glance/compare.py:916: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif (len(aData.shape) is 2) :
/data/users/adesmet/glance-testing/glance/pyglance/glance/plot.py:50: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  isParent = not (pid is 0)
/data/users/adesmet/glance-testing/glance/pyglance/glance/plot.py:101: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if not (pid is 0) :
/data/users/adesmet/glance-testing/glance/pyglance/glance/plotcreatefns.py:739: SyntaxWarning: "is" with a literal. Did you mean "=="?
  assert(len(aData.shape) is 1)
/data/users/adesmet/glance-testing/glance/pyglance/glance/config_organizer.py:114: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if (len(requestedNames) is 0) :
/data/users/adesmet/glance-testing/glance/pyglance/glance/config_organizer.py:220: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if (len(requestedNames) is 0) :
/data/users/adesmet/glance-testing/glance/pyglance/glance/util.py:93: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if totalDataPts is 0 :

The should probably be corrected to ensure correct future behavior.