SyntaxWarning: "is" with a literal

Bug #1996462 reported by psl
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
uranium (Ubuntu)
New
Undecided
Unassigned

Bug Description

Linux Mint 20.3
python3-uranium 4.4.1-1

I see warning when I install "cura" package

$ sudo apt install cura
...
Setting up python3-uranium (4.4.1-1) ...
/usr/lib/python3/dist-packages/UM/View/GL/ShaderProgram.py:326: . Did you mean "=="?
  elif type(value) is list and len(value) is 2:
/usr/lib/python3/dist-packages/UM/View/GL/ShaderProgram.py:328: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif type(value) is list and len(value) is 3:
/usr/lib/python3/dist-packages/UM/View/GL/ShaderProgram.py:330: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif type(value) is list and len(value) is 4:
/usr/lib/python3/dist-packages/UM/View/GL/ShaderProgram.py:332: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif type(value) is list and type(value[0]) is list and len(value[0]) is 2:
Setting up python3-savitar:amd64 (4.4.1-2build1) ...
Setting up uranium-plugins (4.4.1-1) ...
...

File /usr/lib/python3/dist-packages/UM/View/GL/ShaderProgram.py
uses "is" operator in a wrong way...

Simple demo:

$ cat test-is.py
#!/usr/bin/python3

s3 = "abc"
x = 1 + 2
print (len(s3), 3, x)
print (len(s3) is 3) # this is not good, python doesn't like this!!
print (len(s3) == 3)
print (len(s3) is x) # no problem for python...
print (len(s3) == x)

$ python3 test-is.py
test-is.py:6: SyntaxWarning: "is" with a literal. Did you mean "=="?
  print (len(s3) is 3) # this is not good, python doesn't like this!!
3 3 3
True
True
True
True

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.