From: Chuang Zhu Date: Wed, 10 Jul 2024 12:57:18 +0000 (+0200) Subject: bindings: python: fix line request by name with multiple entries X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=237fd2c0597e720980023975250497d30aad1c12;p=qemu-gpiodev%2Flibgpiod.git bindings: python: fix line request by name with multiple entries When multiple entries are requested using line names in Chip.request_lines(), only the the last entry is added to LineRequest._name_map, causing a ValueError when trying to use functions like LineRequest.set_value() on any former entries. Move the required variables to the correct scope. Signed-off-by: Chuang Zhu [Bartosz: tweak the commit message] Co-developed-by: Bartosz Golaszewski Reviewed-by: Kent Gibson Link: https://lore.kernel.org/r/20240710125719.33655-2-brgl@bgdev.pl Signed-off-by: Bartosz Golaszewski --- diff --git a/bindings/python/gpiod/chip.py b/bindings/python/gpiod/chip.py index 47bda11..7692ba4 100644 --- a/bindings/python/gpiod/chip.py +++ b/bindings/python/gpiod/chip.py @@ -279,11 +279,12 @@ class Chip: else: mapped_output_values = None + name_map = dict() + offset_map = dict() + global_output_values = list() + for lines, settings in config.items(): offsets = list() - name_map = dict() - offset_map = dict() - global_output_values = list() if isinstance(lines, int) or isinstance(lines, str): lines = (lines,)