Skip to content

Inconsistent error messages of open functions in io module implementations  #127609

@donBarbos

Description

@donBarbos

Bug report

Bug description:

list where I found error message inconsistencies:

  1. io.open()
    • _io impl raise: TypeError: open() missing required argument 'file' (pos 1)
    • _pyio impl raise: TypeError: open() missing 1 required positional argument: 'file'
  2. io.open("file.txt", mode="")
    • _io impl raise: ValueError: Must have exactly one of create/read/write/append mode and at most one plus
    • _pyio impl raise: ValueError: must have exactly one of read/write/append mode
  3. io.open("file.txt", mode=None)
    • _io impl raise: TypeError: open() argument 'mode' must be str, not None
    • _pyio impl raise: TypeError: invalid mode: None
  4. io.open('file.txt', buffering="")
    • _io impl raise: TypeError: 'str' object cannot be interpreted as an integer
    • _pyio impl raise: TypeError: invalid buffering: ''
  5. io.open('file.txt', encoding=0)
    • _io impl raise: TypeError: open() argument 'encoding' must be str or None, not int
    • _pyio impl raise: TypeError: invalid encoding: 0
  6. io.open('file.txt', errors=0)
    • _io impl raise: TypeError: open() argument 'errors' must be str or None, not int
    • _pyio impl raise: TypeError: invalid errors: 0
  7. io.open('file.txt', newline=0)
    • _io impl raise: TypeError: open() argument 'newline' must be str or None, not int
    • _pyio impl raise: TypeError: illegal newline type: <class 'int'>

I'm ready to take on

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirstdlibStandard Library Python modules in the Lib/ directorytopic-IOtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions