Operator `is` should not be used for comparing integers or strings (SyntaxWarnings with Python 3.8+)
hadrava opened this issue · 2 comments
hadrava commented
Running the wizconfig.py
with Python 3.9.2 (and probably any version 3.8+) will produce lot of warnings:
$ python3 -V
Python 3.9.2
$ python3 wizconfig.py -s
WIZnet-S2E-Tool/wizconfig.py:456: SyntaxWarning: "is" with a literal. Did you mean "=="?
if len(mac_list) is 0:
WIZnet-S2E-Tool/WIZ750CMDSET.py:135: SyntaxWarning: "is" with a literal. Did you mean "=="?
if self.isvalidcommand(cmdstr) is 1:
WIZnet-S2E-Tool/WIZ750CMDSET.py:166: SyntaxWarning: "is" with a literal. Did you mean "=="?
if self.cmdset[cmdstr][3] is "RW":
WIZnet-S2E-Tool/WIZ752CMDSET.py:182: SyntaxWarning: "is" with a literal. Did you mean "=="?
if self.isvalidcommand(cmdstr) is 1:
WIZnet-S2E-Tool/WIZ752CMDSET.py:211: SyntaxWarning: "is" with a literal. Did you mean "=="?
if self.cmdset[cmdstr][3] is "RW":
WIZnet-S2E-Tool/WIZMSGHandler.py:73: SyntaxWarning: "is" with a literal. Did you mean "=="?
if cmd[0] is "MA":
WIZnet-S2E-Tool/FWUploadThread.py:131: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if self.resp is not '':
WIZnet-S2E-Tool/FWUploadThread.py:136: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if self.resp is not '':
WIZnet-S2E-Tool/FWUploadThread.py:206: SyntaxWarning: "is not" with a literal. Did you mean "!="?
while self.remainbytes is not 0:
WIZnet-S2E-Tool/FWUploadThread.py:247: SyntaxWarning: "is" with a literal. Did you mean "=="?
if self.istimeout is 1:
WIZnet-S2E-Tool/wizsocket/TCPClient.py:211: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if self.sock is not 0:
Operator is
should not be used to compare integers. Current code works only thanks to the implementation details of CPython: https://stackoverflow.com/a/28864111/13165974
renakim commented
That's right. I've done the fix, but the update has been delayed. I'll release a new version soon.
Thank you for the leave issue.