Skip to content

[BUG] Unassigned Variable Name (introduced in #12) #17

Open
@nathancartlidge

Description

@nathancartlidge

Describe the bug
The output function (as modified in #12) uses an incorrect variable name channel instead of channels in the case where only a single channel is provided. This variable will be unassigned

(see https://github.com/codenio/Mock.GPIO/blob/b5f98aa65cc3e7ecf69941605515003ee13aea3c/Mock/GPIO.py#L132C1-L136C87)

def output(channels, values):
    ...
    else:
        if type(values) is list or type(values) is tuple:
            for value in values:
                logger.info("Output channel : {} with value : {}".format(channel, value))
        else:
            logger.info("Output channel : {} with value : {}".format(channel, values))

To Reproduce
Steps to reproduce the behavior:

import Mock.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(15, GPIO.OUT)
GPIO.output(15, 1)

This produces an UnboundLocalError

Expected behavior
This should not produce an UnboundLocalError

Desktop (please complete the following information):
Windows 11 / Python 3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions