8000 machine module: handling of unsupported args · Issue #7475 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content
machine module: handling of unsupported args #7475
Open
@peterhinch

Description

@peterhinch

This showed up using pin IRQ's but the problem prompted contemplating the general issue. The docs state that the hard arg for Pin.irq() is not supported by all ports. Accordingly the line

xirq = pin_x.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=self._x_cb, hard=True)

fails on ESP32 with "TypeError: extra keyword arguments given". The obvious (ugly) way to make this portable is to trap the exception and try again without the offending arg. This could become unmanageable if there were multiple args with platform-dependent support.

The best solution is moot. One option would be to accept and silently ignore unsupported args, but this isn't very user friendly. Another would be to accept and ignore the arg, but throw (say) ValueError. Done in such a way as to show which arg is problematic, and in such a way that the handler can be null.

Given that the purpose of machine is to facilitate portability, I think this issue is worth review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0