jmespath/netaddr SyntaxWarning: "is" with a literal when installing ansible.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ansible (Ubuntu) |
Invalid
|
Undecided
|
Unassigned | ||
Bionic |
Won't Fix
|
Undecided
|
Unassigned | ||
Focal |
Won't Fix
|
Undecided
|
Unassigned | ||
Hirsute |
Won't Fix
|
Undecided
|
Unassigned | ||
Impish |
Invalid
|
Undecided
|
Unassigned | ||
python-jmespath (Debian) |
Fix Released
|
Unknown
|
|||
python-jmespath (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Bionic |
Fix Released
|
Undecided
|
Eric Desrochers | ||
Focal |
Fix Released
|
Undecided
|
Eric Desrochers | ||
Hirsute |
Fix Released
|
Undecided
|
Unassigned | ||
Impish |
Fix Released
|
Undecided
|
Unassigned | ||
python-netaddr (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned | ||
Bionic |
In Progress
|
Undecided
|
Unassigned | ||
Focal |
Fix Released
|
Undecided
|
Eric Desrochers | ||
Hirsute |
Confirmed
|
Undecided
|
Unassigned | ||
Impish |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
[IMPACT]
* Allow broader Ops/Eng team to consume Ansible from our packages instead of the upstream PyPi repositories in order to fix this warning.
* Sanitize package installation:
Setting up python3-jmespath (0.9.4-2) ...
/usr/lib/
Setting up python3-netaddr (0.7.19-3) ...
/usr/lib/
if word_sep is not '':
jmespath and netaddr are 2 runtime dependencies of ansible.
The syntaxwarning while purely cosmetic, may mislead user and their trust in using a sane and tested package.
[TEST CASE]
* Install ansible with syntax fixed of netaddr and jmespath with py3.8
* Install ansible with syntax fixed of netaddr and jmespath with py2
It shouldn't report any syntaxwarning after both fixes.
Extra test case:
** Scenario #1 **
$ pull-lp-source python-jmespath
$ cd python-jmespath*
$ python3-coverage run jmespath/visitor.py
jmespath/
if x is 0 or x is 1:
jmespath/
if x is 0 or x is 1:
jmespath/
elif y is 0 or y is 1:
jmespath/
elif y is 0 or y is 1:
jmespath/
if original_result is 0:
$ quilt push -a
Applying patch 0001-satisfy-
patching file jmespath/visitor.py
$ python3-coverage run jmespath/visitor.py
** Scenario #2 **
$ pull-lp-source python-jmespath
$ cd python-jmespath*
$ nosetests3
/tmp/jmes/
if x is 0 or x is 1:
/tmp/jmes/
if x is 0 or x is 1:
/tmp/jmes/
elif y is 0 or y is 1:
/tmp/jmes/
elif y is 0 or y is 1:
/tmp/jmes/
if original_result is 0:
.......
-------
Ran 41 tests in 0.039s
OK
$ quilt push -a
Applying patch 0001-satisfy-
patching file jmespath/visitor.py
Now at patch 0001-satisfy-
$ nosetests3
.......
-------
Ran 41 tests in 0.021s
OK
$ nosetests
.......
-------
Ran 41 tests in 0.016s
OK
** Scenario #3 **
This could be reproduced outside python-jmespath as follows (a little script I have written to compare result between py2 and py3 :
# reproducer_test.py
----
def reproducer(x,y):
if x is 0 or x is 1:
return y is True or y is False
elif y is 0 or y is 1:
return x is True or x is False
print(reproduce
print(reproduce
---
$ python2 reproducer_test.py
False
False
$ python3 -W ignore reproducer_test.py
False
False
$ python3 reproducer_test.py
test.py:2: SyntaxWarning: "is" with a literal. Did you mean "=="?
if x is 0 or x is 1:
test.py:2: SyntaxWarning: "is" with a literal. Did you mean "=="?
if x is 0 or x is 1:
test.py:4: SyntaxWarning: "is" with a literal. Did you mean "=="?
elif y is 0 or y is 1:
test.py:4: SyntaxWarning: "is" with a literal. Did you mean "=="?
elif y is 0 or y is 1:
False
False
With the fix in a small scale (Again, using my reproducer_
# reproducer_test.py
----
def reproducer(x,y):
# if x is 0 or x is 1:
if type(x) is int and (x == 0 or x == 1):
return y is True or y is False
# elif y is 0 or y is 1:
elif type(y) is int and (y == 0 or y == 1):
return x is True or x is False
print(reproduce
print(reproduce
---
# python2 reproducer_test.py
False
False
$ python3 reproducer_test.py
False
False
The above proves that it maintains compatibility in py2 while fixing the "SyntaxWarning "in py3.
[WHERE PROBLEM COULD OCCURS]
Risk: Low
* The fix maintain backward compatibility tested with python3-
This package lack of test suite and coverage for things that could have been easily avoided with proper test in place. There may or may not be other places in other code path generating syntax warning, as this is not well tested I'm afraid.
In general, looking upstream:
* No observed regression caused by this fix in upstream issues nor in the Ubuntu release where the fix has landed (Focal/Hirsute).
* No other py3.8 commits (either fix and/or regression fix) found in the project git log.
[OTHER INFORMATIONS]
Upstream issue:
https:/
Upstream commit:
https:/
[ORIGINAL DESCRIPTIONS]
As reported upstream
https:/
Problems installing jmespath in Ubuntu 20.04 LTS
Setting up python3-jmespath (0.9.4-2) ...
/usr/lib/
Fixed upstream in https:/
Impact: this causes applications like Ansible that have dependencies on python-jmespath to send out warnings. Caused by language changes in Python 3.8.
System is Ubuntu 20.04 LTS on a Pi 4.
emv@pinnatus:~$ apt-cache policy python3-jmespath
python3-jmespath:
Installed: 0.9.4-2
Candidate: 0.9.4-2
Version table:
*** 0.9.4-2 500
500 http://
100 /var/lib/
Changed in python-jmespath (Debian): | |
status: | Unknown → Fix Released |
Changed in python-jmespath (Ubuntu Hirsute): | |
status: | New → Fix Released |
description: | updated |
description: | updated |
description: | updated |
tags: | added: seg sts |
Changed in python-jmespath (Ubuntu Focal): | |
status: | New → Confirmed |
Changed in python-jmespath (Ubuntu Bionic): | |
status: | New → Confirmed |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
Changed in ansible (Ubuntu Bionic): | |
status: | New → Won't Fix |
Changed in ansible (Ubuntu Focal): | |
status: | New → Won't Fix |
Changed in ansible (Ubuntu Hirsute): | |
status: | New → Won't Fix |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
Changed in python-jmespath (Ubuntu Focal): | |
assignee: | nobody → Eric Desrochers (slashd) |
status: | Confirmed → In Progress |
Changed in python-jmespath (Ubuntu Bionic): | |
assignee: | nobody → Eric Desrochers (slashd) |
status: | Confirmed → In Progress |
tags: | added: sts-sponsors-halves |
Changed in python-netaddr (Ubuntu Focal): | |
assignee: | nobody → Eric Desrochers (slashd) |
status: | New → In Progress |
Changed in python-netaddr (Ubuntu Bionic): | |
assignee: | nobody → Eric Desrochers (slashd) |
status: | New → In Progress |
summary: |
- jmespath SyntaxWarning: "is" with a literal. + jmespath/netaddr SyntaxWarning: "is" with a literal when installing + ansible. |
description: | updated |
description: | updated |
tags: | added: patch |
Changed in python-netaddr (Ubuntu Bionic): | |
assignee: | Eric Desrochers (slashd) → nobody |
Status changed to 'Confirmed' because the bug affects multiple users.