Commit eab6201
lxml: use == not is when comparing os.name to a string literal
`lxml/lxmlGramplet.py:400` and `:758` both use:
if os.name is 'nt':
Python 3.12+ emits a SyntaxWarning on this idiom:
SyntaxWarning: "is" with 'str' literal. Did you mean "=="?
`is` checks object identity, not equality. The expression happens to
evaluate as expected on CPython today only because short strings get
interned during compilation, so `os.name` and the literal `'nt'` end
up pointing at the same object — but that's an implementation detail
of the interpreter and not guaranteed by the language. The right test
is value equality.
Two other call sites in the same file already use `==` for the same
comparison (`lxmlGramplet.py:161` and `:181`), so this also brings the
file's style into self-consistency.
Verified via `python3 -W error::SyntaxWarning -m py_compile
lxml/lxmlGramplet.py` (exits 0).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 42a4029 commit eab6201
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
400 | | - | |
| 400 | + | |
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
| |||
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
758 | | - | |
| 758 | + | |
759 | 759 | | |
760 | 760 | | |
761 | 761 | | |
| |||
0 commit comments