[Bug 1917318] Re: code confuses identity and equality (fixed upstream)
Rolf Leggewie
1917318 at bugs.launchpad.net
Thu Apr 8 18:46:01 UTC 2021
** Description changed:
IMPACT:
Python 3.8 has started to emit warnings for code that confuses equality
and identity. For more background see https://adamj.eu/tech/2020/01/21
/why-does-python-3-8-syntaxwarning-for-is-literal/
While it is just a warning, it is very visible when running ansible on
focal for example, to the point of making the output incredibly hard to
- follow. Furthermore, the incorrect indifference between identity and
- equality might be creating true bugs as discussed in above blog entry.
- It seems advisable to fix this incorrect code when found.
+ follow. Furthermore, the indifference between identity and equality
+ might be creating true bugs as discussed in above blog entry. It seems
+ advisable to fix this incorrect code when found.
TEST CASE:
tbd
REGRESSION POTENTIAL:
tbd
-
Original report below:
======================
lsb_release -rd
Description: Ubuntu 20.04.2 LTS
Release: 20.04
apt-cache policy ansible
ansible:
Installed: 2.9.6+dfsg-1
Candidate: 2.9.6+dfsg-1
Version table:
*** 2.9.6+dfsg-1 500
500 http://tw.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
500 http://tw.archive.ubuntu.com/ubuntu focal/universe i386 Packages
100 /var/lib/dpkg/status
Hi, I install ansible have output some log:
Selecting previously unselected package python3-markupsafe.
(Reading database ... 194136 files and directories currently installed.)
Preparing to unpack .../00-python3-markupsafe_1.1.0-1build2_amd64.deb ...
Unpacking python3-markupsafe (1.1.0-1build2) ...
Selecting previously unselected package python3-jinja2.
Preparing to unpack .../01-python3-jinja2_2.10.1-2_all.deb ...
Unpacking python3-jinja2 (2.10.1-2) ...
Selecting previously unselected package python3-dnspython.
Preparing to unpack .../02-python3-dnspython_1.16.0-1build1_all.deb ...
Unpacking python3-dnspython (1.16.0-1build1) ...
Selecting previously unselected package ieee-data.
Preparing to unpack .../03-ieee-data_20180805.1_all.deb ...
Unpacking ieee-data (20180805.1) ...
Selecting previously unselected package python3-netaddr.
Preparing to unpack .../04-python3-netaddr_0.7.19-3_all.deb ...
Unpacking python3-netaddr (0.7.19-3) ...
Selecting previously unselected package ansible.
Preparing to unpack .../05-ansible_2.9.6+dfsg-1_all.deb ...
Unpacking ansible (2.9.6+dfsg-1) ...
Selecting previously unselected package python3-argcomplete.
Preparing to unpack .../06-python3-argcomplete_1.8.1-1.3ubuntu1_all.deb ...
Unpacking python3-argcomplete (1.8.1-1.3ubuntu1) ...
Selecting previously unselected package python3-jmespath.
Preparing to unpack .../07-python3-jmespath_0.9.4-2_all.deb ...
Unpacking python3-jmespath (0.9.4-2) ...
Selecting previously unselected package python3-kerberos.
Preparing to unpack .../08-python3-kerberos_1.1.14-3.1build1_amd64.deb ...
Unpacking python3-kerberos (1.1.14-3.1build1) ...
Selecting previously unselected package python3-lockfile.
Preparing to unpack .../09-python3-lockfile_1%3a0.12.2-2ubuntu2_all.deb ...
Unpacking python3-lockfile (1:0.12.2-2ubuntu2) ...
Selecting previously unselected package python3-libcloud.
Preparing to unpack .../10-python3-libcloud_2.8.0-1_all.deb ...
Unpacking python3-libcloud (2.8.0-1) ...
Selecting previously unselected package python3-ntlm-auth.
Preparing to unpack .../11-python3-ntlm-auth_1.1.0-1_all.deb ...
Unpacking python3-ntlm-auth (1.1.0-1) ...
Selecting previously unselected package python3-requests-kerberos.
Preparing to unpack .../12-python3-requests-kerberos_0.12.0-2_all.deb ...
Unpacking python3-requests-kerberos (0.12.0-2) ...
Selecting previously unselected package python3-requests-ntlm.
Preparing to unpack .../13-python3-requests-ntlm_1.1.0-1_all.deb ...
Unpacking python3-requests-ntlm (1.1.0-1) ...
Selecting previously unselected package python3-selinux.
Preparing to unpack .../14-python3-selinux_3.0-1build2_amd64.deb ...
Unpacking python3-selinux (3.0-1build2) ...
Selecting previously unselected package python3-xmltodict.
Preparing to unpack .../15-python3-xmltodict_0.12.0-1_all.deb ...
Unpacking python3-xmltodict (0.12.0-1) ...
Selecting previously unselected package python3-winrm.
Preparing to unpack .../16-python3-winrm_0.3.0-2_all.deb ...
Unpacking python3-winrm (0.3.0-2) ...
Setting up python3-lockfile (1:0.12.2-2ubuntu2) ...
Setting up python3-ntlm-auth (1.1.0-1) ...
Setting up python3-kerberos (1.1.14-3.1build1) ...
Setting up python3-libcloud (2.8.0-1) ...
Setting up python3-markupsafe (1.1.0-1build2) ...
Setting up python3-xmltodict (0.12.0-1) ...
Setting up python3-jinja2 (2.10.1-2) ...
Setting up python3-jmespath (0.9.4-2) ...
/usr/lib/python3/dist-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
if x is 0 or x is 1:
/usr/lib/python3/dist-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
if x is 0 or x is 1:
/usr/lib/python3/dist-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
elif y is 0 or y is 1:
/usr/lib/python3/dist-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
elif y is 0 or y is 1:
/usr/lib/python3/dist-packages/jmespath/visitor.py:260: SyntaxWarning: "is" with a literal. Did you mean "=="?
if original_result is 0:
Setting up python3-requests-kerberos (0.12.0-2) ...
Setting up ieee-data (20180805.1) ...
Setting up python3-dnspython (1.16.0-1build1) ...
Setting up python3-selinux (3.0-1build2) ...
Setting up python3-argcomplete (1.8.1-1.3ubuntu1) ...
Setting up python3-requests-ntlm (1.1.0-1) ...
Setting up python3-netaddr (0.7.19-3) ...
/usr/lib/python3/dist-packages/netaddr/strategy/__init__.py:189: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if word_sep is not '':
Setting up python3-winrm (0.3.0-2) ...
Setting up ansible (2.9.6+dfsg-1) ...
Processing triggers for man-db (2.9.1-1) ...
--
You received this bug notification because you are a member of Ubuntu
OpenStack, which is subscribed to python-netaddr in Ubuntu.
https://bugs.launchpad.net/bugs/1917318
Title:
code confuses identity and equality (fixed upstream)
Status in ansible package in Ubuntu:
Invalid
Status in python-jmespath package in Ubuntu:
Confirmed
Status in python-netaddr package in Ubuntu:
Confirmed
Status in Debian:
Fix Released
Bug description:
IMPACT:
Python 3.8 has started to emit warnings for code that confuses
equality and identity. For more background see
https://adamj.eu/tech/2020/01/21/why-does-python-3-8-syntaxwarning-
for-is-literal/
While it is just a warning, it is very visible when running ansible on
focal for example, to the point of making the output incredibly hard
to follow. Furthermore, the indifference between identity and
equality might be creating true bugs as discussed in above blog entry.
It seems advisable to fix this incorrect code when found.
TEST CASE:
tbd
REGRESSION POTENTIAL:
The current code checks for identity via "is" and and "is not"...
Original report below:
======================
lsb_release -rd
Description: Ubuntu 20.04.2 LTS
Release: 20.04
apt-cache policy ansible
ansible:
Installed: 2.9.6+dfsg-1
Candidate: 2.9.6+dfsg-1
Version table:
*** 2.9.6+dfsg-1 500
500 http://tw.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
500 http://tw.archive.ubuntu.com/ubuntu focal/universe i386 Packages
100 /var/lib/dpkg/status
Hi, I install ansible have output some log:
Selecting previously unselected package python3-markupsafe.
(Reading database ... 194136 files and directories currently installed.)
Preparing to unpack .../00-python3-markupsafe_1.1.0-1build2_amd64.deb ...
Unpacking python3-markupsafe (1.1.0-1build2) ...
Selecting previously unselected package python3-jinja2.
Preparing to unpack .../01-python3-jinja2_2.10.1-2_all.deb ...
Unpacking python3-jinja2 (2.10.1-2) ...
Selecting previously unselected package python3-dnspython.
Preparing to unpack .../02-python3-dnspython_1.16.0-1build1_all.deb ...
Unpacking python3-dnspython (1.16.0-1build1) ...
Selecting previously unselected package ieee-data.
Preparing to unpack .../03-ieee-data_20180805.1_all.deb ...
Unpacking ieee-data (20180805.1) ...
Selecting previously unselected package python3-netaddr.
Preparing to unpack .../04-python3-netaddr_0.7.19-3_all.deb ...
Unpacking python3-netaddr (0.7.19-3) ...
Selecting previously unselected package ansible.
Preparing to unpack .../05-ansible_2.9.6+dfsg-1_all.deb ...
Unpacking ansible (2.9.6+dfsg-1) ...
Selecting previously unselected package python3-argcomplete.
Preparing to unpack .../06-python3-argcomplete_1.8.1-1.3ubuntu1_all.deb ...
Unpacking python3-argcomplete (1.8.1-1.3ubuntu1) ...
Selecting previously unselected package python3-jmespath.
Preparing to unpack .../07-python3-jmespath_0.9.4-2_all.deb ...
Unpacking python3-jmespath (0.9.4-2) ...
Selecting previously unselected package python3-kerberos.
Preparing to unpack .../08-python3-kerberos_1.1.14-3.1build1_amd64.deb ...
Unpacking python3-kerberos (1.1.14-3.1build1) ...
Selecting previously unselected package python3-lockfile.
Preparing to unpack .../09-python3-lockfile_1%3a0.12.2-2ubuntu2_all.deb ...
Unpacking python3-lockfile (1:0.12.2-2ubuntu2) ...
Selecting previously unselected package python3-libcloud.
Preparing to unpack .../10-python3-libcloud_2.8.0-1_all.deb ...
Unpacking python3-libcloud (2.8.0-1) ...
Selecting previously unselected package python3-ntlm-auth.
Preparing to unpack .../11-python3-ntlm-auth_1.1.0-1_all.deb ...
Unpacking python3-ntlm-auth (1.1.0-1) ...
Selecting previously unselected package python3-requests-kerberos.
Preparing to unpack .../12-python3-requests-kerberos_0.12.0-2_all.deb ...
Unpacking python3-requests-kerberos (0.12.0-2) ...
Selecting previously unselected package python3-requests-ntlm.
Preparing to unpack .../13-python3-requests-ntlm_1.1.0-1_all.deb ...
Unpacking python3-requests-ntlm (1.1.0-1) ...
Selecting previously unselected package python3-selinux.
Preparing to unpack .../14-python3-selinux_3.0-1build2_amd64.deb ...
Unpacking python3-selinux (3.0-1build2) ...
Selecting previously unselected package python3-xmltodict.
Preparing to unpack .../15-python3-xmltodict_0.12.0-1_all.deb ...
Unpacking python3-xmltodict (0.12.0-1) ...
Selecting previously unselected package python3-winrm.
Preparing to unpack .../16-python3-winrm_0.3.0-2_all.deb ...
Unpacking python3-winrm (0.3.0-2) ...
Setting up python3-lockfile (1:0.12.2-2ubuntu2) ...
Setting up python3-ntlm-auth (1.1.0-1) ...
Setting up python3-kerberos (1.1.14-3.1build1) ...
Setting up python3-libcloud (2.8.0-1) ...
Setting up python3-markupsafe (1.1.0-1build2) ...
Setting up python3-xmltodict (0.12.0-1) ...
Setting up python3-jinja2 (2.10.1-2) ...
Setting up python3-jmespath (0.9.4-2) ...
/usr/lib/python3/dist-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
if x is 0 or x is 1:
/usr/lib/python3/dist-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
if x is 0 or x is 1:
/usr/lib/python3/dist-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
elif y is 0 or y is 1:
/usr/lib/python3/dist-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
elif y is 0 or y is 1:
/usr/lib/python3/dist-packages/jmespath/visitor.py:260: SyntaxWarning: "is" with a literal. Did you mean "=="?
if original_result is 0:
Setting up python3-requests-kerberos (0.12.0-2) ...
Setting up ieee-data (20180805.1) ...
Setting up python3-dnspython (1.16.0-1build1) ...
Setting up python3-selinux (3.0-1build2) ...
Setting up python3-argcomplete (1.8.1-1.3ubuntu1) ...
Setting up python3-requests-ntlm (1.1.0-1) ...
Setting up python3-netaddr (0.7.19-3) ...
/usr/lib/python3/dist-packages/netaddr/strategy/__init__.py:189: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if word_sep is not '':
Setting up python3-winrm (0.3.0-2) ...
Setting up ansible (2.9.6+dfsg-1) ...
Processing triggers for man-db (2.9.1-1) ...
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ansible/+bug/1917318/+subscriptions
More information about the Ubuntu-openstack-bugs
mailing list