Skip to content

Object init error string shows wrong number of arguments #3112

@dunkmann00

Description

@dunkmann00

When initializing an object, the error that is produced when the wrong number of positional arguments is given shows the wrong number of arguments given and required. It is off by +1. From my testing, this only happens when the object being initialized is a subclass.

Example:

import board
import neopixel # subclass of either _pixelbuf or pypixelbuf, depending on CP version and/or board

extra_arg = None

pixels = neopixel.NeoPixel(board.D5, 24, extra_arg) # This is supposed to have only 2 positional arguments here

Output:

TypeError: function takes 4 positional arguments but 5 were given

Expected Output:

TypeError: function takes 3 positional arguments but 4 were given

I tested this on an itsybitsy_m4_express running CP 5.3.0 and 5.4.0-beta.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions