Skip to content

OSError has invalid __new__ #2914

Closed

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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