Skip to content

OSError has invalid __new__ #2914

Closed
@sobolevn

Description

@sobolevn

Feature

Right now OSError has a standard __new__, which is not correct. Because it is a special case in CPython:

>>> OSError()
OSError()
>>> OSError(1)
OSError(1)
>>> OSError(1, 2)
PermissionError(1, 2)

RustPython:

>>>>> OSError()  # ok
OSError()
>>>>> OSError(1)  # ok
OSError(1)
>>>>> OSError(1, 2)  # error
OSError(1, 2)

Python Documentation

Source code: https://github.com/python/cpython/blob/ecc3c8e4216958d85385bf2467441c975128f26c/Objects/exceptions.c#L991-L1003

Related #2897
Related #2771

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