Python utility library
  • Python 98.5%
  • Makefile 1.3%
  • Shell 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jan Lindemann b192207bbd
Options.get(): Fix inverted by_index check
The by_index branch of Options.get() raises KeyError for every integer
index, because the first isinstance guard is inverted: it fires for exactly
the keys the branch is supposed to handle, so the range check and the
lookup in the list of parsed keys below it are dead code. A non-integer key
with by_index set slips past the guard and falls through to the regular key
lookup instead. A previous make-check fallout commit flipped the original
type(key) != int test into a positive isinstance test, and a later mypy fix
then added redundant isinstance guards to the unreachable branches,
cementing the broken flow.

Invert the guard back to not isinstance(key, int), so that a non-integer
key raises KeyError, an in-range integer index returns the key stored at
that position in the option string, and an out-of-range index returns the
default or raises KeyError. Drop the redundant isinstance guards from the
now-reachable branches.

TODO: The bug actually made "make -C test/parse_opts run" fail, but since
jw-python's nightly CI doesn't run that, this has gone unnoticed. The test
now passes, but should be replaced with a better test (executed by "make
test", and pytest-based).

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-09-18 09:44:26 +02:00
.github/workflows ci.yaml: enable-email-notifications: true 2026-06-08 14:55:11 +02:00
bin Rename the MODDIR makefile variable to JWBDIR 2019-06-29 23:32:20 +02:00
conf Rename the MODDIR makefile variable to JWBDIR 2019-06-29 23:32:20 +02:00
make stree.StringTree: Add unit tests 2026-08-12 23:10:12 +00:00
scripts Add missing async keywords to jwutils.Cmd.run() reimplementations 2020-02-10 19:49:46 +01:00
src Options.get(): Fix inverted by_index check 2026-09-18 09:44:26 +02:00
test test: Fix mypy strict errors in test tree 2026-09-13 13:50:15 +02:00
.gitignore .gitignore: Update 2: Run "make gitignore" 2026-09-13 13:47:08 +02:00
HASH Release 1.0.0-56@suse-tumbleweed/x86_64 2026-09-17 05:33:20 +00:00
Makefile Makefile: Include py-topdir.mk 2026-06-12 04:55:47 +02:00
RELEASES Release 1.0.0-56@suse-tumbleweed/x86_64 2026-09-17 05:33:20 +00:00
VERSION Start version: 1.0.0-56 2026-09-16 23:12:58 +00:00