Discussion:
Bug#993132: python3-fife: prints "is"/"is not" used-with-a-literal warnings at install time
(too old to reply)
The Wanderer
2021-08-27 17:30:01 UTC
Permalink
Package: python3-fife
Version: 0.4.2-3
Severity: normal

Dear Maintainer,

When I installed python3-fife as a dependency from another package, I
saw the following printed in the console:


Setting up python3-fife (0.4.2-3) ...
/usr/lib/python3/dist-packages/fife/extensions/fife_settings.py:301:
SyntaxWarning: "is not" with a literal. Did you mean "!="?
if module is not "FIFE":
/usr/lib/python3/dist-packages/fife/extensions/fife_settings.py:435:
SyntaxWarning: "is" with a literal. Did you mean "=="?
if module is "FIFE":
/usr/lib/python3/dist-packages/fife/extensions/pychan/widgets/animationicon.py:193:
SyntaxWarning: "is not" with a literal. Did you mean "!="?
if anim is not "":
/usr/lib/python3/dist-packages/fife/extensions/pychan/widgets/curvegraph.py:164:
SyntaxWarning: "is" with a literal. Did you mean "=="?
if coordinates is None or len(coordinates) is 0:
/usr/lib/python3/dist-packages/fife/extensions/pychan/widgets/linegraph.py:157:
SyntaxWarning: "is" with a literal. Did you mean "=="?
if coordinates is None or len(coordinates) is 0:
/usr/lib/python3/dist-packages/fife/extensions/pychan/widgets/pointgraph.py:157:
SyntaxWarning: "is" with a literal. Did you mean "=="?
if coordinates is None or len(coordinates) is 0:
/usr/lib/python3/dist-packages/fife/extensions/pychan/widgets/widget.py:1038:
SyntaxWarning: "is" with a literal. Did you mean "=="?
if len(margin) is 4:
/usr/lib/python3/dist-packages/fife/extensions/pychan/widgets/widget.py:1044:
SyntaxWarning: "is" with a literal. Did you mean "=="?
elif len(margin) is 3:
/usr/lib/python3/dist-packages/fife/extensions/pychan/widgets/widget.py:1050:
SyntaxWarning: "is" with a literal. Did you mean "=="?
elif len(margin) is 2:
/usr/lib/python3/dist-packages/fife/extensions/pychan/widgets/widget.py:1056:
SyntaxWarning: "is" with a literal. Did you mean "=="?
elif len(margin) is 1:
/usr/lib/python3/dist-packages/fife/extensions/pychan/widgets/widget.py:1068:
SyntaxWarning: "is" with a literal. Did you mean "=="?
if len(padding) is 4:
/usr/lib/python3/dist-packages/fife/extensions/pychan/widgets/widget.py:1074:
SyntaxWarning: "is" with a literal. Did you mean "=="?
elif len(padding) is 3:
/usr/lib/python3/dist-packages/fife/extensions/pychan/widgets/widget.py:1080:
SyntaxWarning: "is" with a literal. Did you mean "=="?
elif len(padding) is 2:
/usr/lib/python3/dist-packages/fife/extensions/pychan/widgets/widget.py:1086:
SyntaxWarning: "is" with a literal. Did you mean "=="?
elif len(padding) is 1:
/usr/lib/python3/dist-packages/fife/extensions/serializers/xmlmap.py:640: SyntaxWarning:
"is not" with a literal. Did you mean "!="?
if data['s_ref'] is not -1:
/usr/lib/python3/dist-packages/fife/extensions/serializers/xmlmap.py:663: SyntaxWarning:
"is not" with a literal. Did you mean "!="?
if data['s_ref'] is not -1:
/usr/lib/python3/dist-packages/fife/extensions/serializers/xmlmap.py:686: SyntaxWarning:
"is not" with a literal. Did you mean "!="?
if data['s_ref'] is not -1:
/usr/lib/python3/dist-packages/fife/extensions/serializers/xmlmapsaver.py:301:
SyntaxWarning: "is not" with a literal. Did you mean "!="?
if info.getSubdivisions() is not 32:
Setting up unknown-horizons (2019.1-3) ...
/usr/lib/python3/dist-packages/horizons/extscheduler.py:72:
SyntaxWarning: "is" with a literal. Did you mean "=="?
if obj.loops > 0 or obj.loops is -1:


I'm not sufficiently familiar with either the language or the codebase
to be sure about whether these represent harmless warnings (in which
case this bug should be "minor") or could produce actual unintended
behavior, although I think the former is more likely; however, either
way, having this output appear isn't the best user-facing appearance.

Please adjust the package such that this type of output does not appear
at the point of package installation.


-- System Information:
Debian Release: 11.0
APT prefers testing
APT policy: (900, 'testing'), (800, 'stable'), (500, 'testing-debug'),
(500, 'stable-security')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.10.0-8-amd64 (SMP w/12 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE
not set
Shell: /bin/sh linked to /usr/bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled

Versions of packages python3-fife depends on:
ii libboost-filesystem1.74.0 1.74.0-9
ii libc6 2.31-13
ii libfifechan0.1.5 0.1.5-2
ii libgcc-s1 10.2.1-6
ii libgl1 1.3.2-1
ii libglew2.1 2.1.0-4+b1
ii libopenal1 1:1.19.1-2
ii libpng16-16 1.6.37-3
ii libpython3.9 3.9.2-1
ii libsdl2-2.0-0 2.0.14+dfsg2-3
ii libsdl2-image-2.0-0 2.0.5+dfsg1-2
ii libsdl2-ttf-2.0-0 2.0.15+dfsg1-1
ii libstdc++6 10.2.1-6
ii libtinyxml2.6.2v5 2.6.2-4
ii libvorbisfile3 1.3.7-1
ii python3 3.9.2-3
ii zlib1g 1:1.2.11.dfsg-2

python3-fife recommends no packages.

python3-fife suggests no packages.

-- no debconf information
Simon McVittie
2021-08-27 21:00:03 UTC
Permalink
This is a real bug. "is" is identity (pointer) comparison, like comparing
char* in C using "==", so it is usually wrong for anything that isn't
a singleton object such as None.
Post by The Wanderer
Setting up python3-fife (0.4.2-3) ...
SyntaxWarning: "is not" with a literal. Did you mean "!="?
My understanding is that this is genuinely a functional bug: non-trivial
strings in Python are usually allocated separately, so this is like doing
"if (module == "FIFE")" in C, and in practice they will usually compare
unequal, even if module is another string containing the letters "FIFE".
Post by The Wanderer
SyntaxWarning: "is" with a literal. Did you mean "=="?
In CPython, the reference C implementation of Python, integers in a
certain range (I think it's something like -1 to 100) are "interned", so
comparison with "is" will do what the programmer intends - but that's an
implementation detail that might change in a future version, and should
not be relied on. Larger integers are allocated and freed on-demand,
so they will usually compare unequal with "is", even if the numerical
value is equal. Relying on this implementation detail is not portable
to other implementations such as PyPy, and is considered to be bad style
even in CPython.

Conversely, None is a special singleton object, so comparing with
"is None" or "is not None" is correct (and is considered to be good
style).

smcv
Tobias Frost
2022-08-27 14:30:01 UTC
Permalink
Control: tags -1 fixed-upstream patch
Control: forwarded -1 https://github.com/fifengine/fifengine/issues/1082

This seems to be fixed upstream:

https://github.com/fifengine/fifengine/pull/1076
and 
https://github.com/fifengine/fifengine/commit/f37c31c6cea74d50f1d635d876253a7b1f64630b
Loading...