GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Pydoc: fall back to __text_signature__ if inspect.signature() fails · Issue #107782 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
Closed
Pydoc: fall back to __text_signature__ if inspect.signature() fails#107782
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@serhiy-storchaka
serhiy-storchaka
opened on Aug 8, 2023
Issue body actions

Pydoc uses inspect.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() or dict.pop(). It produces a human readable __text_signature__, but it can not be represented as a Signature object, so inspect.signature() fails. Pydoc display generic (...) for such functions.

Since pydoc only needs a string representation of signature, not a Signature object, I propose to use __text_signature__ if inspect.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

  • gh-107782: Pydoc: fall back to __text_signature__ if inspect.signature() fails #107786
  • gh-107782: Use _testcapi to test non-representable signatures #109325
Reacted by Alex Waygood, Kirill Podoprigora and Erlend E. Aasland

Activity

  1. serhiy-storchaka
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Aug 8, 2023
  2. AlexWaygood
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Aug 8, 2023
  3. serhiy-storchaka
    added 2 commits that reference this issue on Aug 8, 2023

    pythongh-107782: Pydoc: fall back to __text_signature__ if inspect.si…

    d92e675

    gh-107782: Pydoc: fall back to __text_signature__ if inspect.signatur…

    a39f0a3
  4. serhiy-storchaka
    closed this as completedon Aug 12, 2023
  5. serhiy-storchaka
    added 2 commits that reference this issue on Sep 12, 2023

    pythongh-107782: Use _testcapi to test non-representable signatures

    5fe56f0

    gh-107782: Use _testcapi to test non-representable signatures (GH-109325

    1f885df
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

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.