Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Pydoc: fall back to __text_signature__ if inspect.signature() fails #107782

Closed
Labels
stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement
@serhiy-storchaka

Description

@serhiy-storchaka

Pydoc usesinspect.signature() to get a function signature.inspect.signature() supports Python functions, and also extension functions defined with Argument Clinic (by parsing the__text_signature__ attribute). Unfortunately Argument Clinic is used with functions whose signature cannot be expressed in Python, e.g.getattr() ordict.pop(). It produces a human readable__text_signature__, but it can not be represented as aSignature object, soinspect.signature() fails. Pydoc display generic(...) for such functions.

Since pydoc only needs a string representation of signature, not aSignature object, I propose to use__text_signature__ ifinspect.signature() fails. It needs only some trivial processing.

Before:

getattr(...)    Get a named attribute from an object.    getattr(x, 'y') is equivalent to x.y    When a default argument is given, it is returned when the attribute doesn't    exist; without it, an exception is raised in that case.

After:

getattr(object, name, default=<unrepresentable>, /)    Get a named attribute from an object.    getattr(x, 'y') is equivalent to x.y    When a default argument is given, it is returned when the attribute doesn't    exist; without it, an exception is raised in that case.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp