Skip to content

Check number of parameters: int.from_bytes() #6419

Closed
@rsbohn

Description

@rsbohn

CircuitPython version

Adafruit CircuitPython 7.3.0-rc.2 on 2022-05-21; Raspberry Pi Pico with rp2040

Code/REPL

b = (0xFEED).to_bytes(2,"little")
# next line is not correct code
x = int.from_bytes(b, 2, "little")
print(x==0xFEED)

Behavior

C Python raises a TypeError if too many arguments:

int.from_bytes(bytes([0xFE,0xED]), 2, "big")
Traceback (most recent call last):
File "", line 1, in
TypeError: from_bytes() takes exactly 2 positional arguments (3 given)

Description

Expectation: Raise TypeError int.from_bytes() is called with more or less than 2 arguments.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions