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 — __text_signature__ parser doesn't handle globals in extension module · Issue #82062 · python/cpython

__text_signature__ parser doesn't handle globals in extension module #82062

New issue
Copy link
New issue
Copy link
Closed
Closed
__text_signature__ parser doesn't handle globals in extension module#82062
Copy link
Labels
3.13only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory

Description

anntzer
mannequin
opened on Aug 18, 2019
Issue body actions
BPO 37881
Nosy @ericsnowcurrently, @anntzer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2019-08-18.13:33:56.559>
labels = ['extension-modules']
title = "__text_signature__ parser doesn't handle globals in extension module"
updated_at = <Date 2020-10-08.11:34:43.922>
user = 'https://github.com/anntzer'

bugs.python.org fields:

activity = <Date 2020-10-08.11:34:43.922>
actor = 'pitrou'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Extension Modules']
creation = <Date 2019-08-18.13:33:56.559>
creator = 'Antony.Lee'
dependencies = []
files = []
hgrepos = []
issue_num = 37881
keywords = []
message_count = 1.0
messages = ['349919']
nosy_count = 3.0
nosy_names = ['eric.snow', 'Antony.Lee', 'Eric Wieser']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue37881'
versions = []

Linked PRs

  • gh-82062: correctly set module for built-in instance methods in inspect.signature() #115270

Activity

  1. anntzer commented on Aug 18, 2019

    @anntzer
    anntzermannequin
    on Aug 18, 2019
    MannequinAuthor
    More actions

    Starting from the custom2 example at https://docs.python.org/3/extending/newtypes_tutorial.html#adding-data-and-methods-to-the-basic-example, change the methods table to

    static PyMethodDef Custom_methods[] = {
        {"foo", (PyCFunction) Custom_foo, METH_VARARGS,
        "foo(x=ONE)\n--\n\nFoos this."
        },
        {NULL}  /* Sentinel */
    };
    

    and add a global ONE to the module dict:

        PyModule_AddObject(m, "ONE", PyLong_FromLong(1));

    Building and running e.g. pydoc on this module results in

        Traceback (most recent call last):
        File ".../lib/python3.7/inspect.py", line 2003, in wrap_value
            value = eval(s, module_dict)
        File "<string>", line 1, in <module>
        NameError: name 'ONE' is not defined
    
        During handling of the above exception, another exception occurred:
    
        Traceback (most recent call last):
        File ".../lib/python3.7/inspect.py", line 2006, in wrap_value
            value = eval(s, sys_module_dict)
        File "<string>", line 1, in <module>
        NameError: name 'ONE' is not defined
    
        During handling of the above exception, another exception occurred:
    
        Traceback (most recent call last):
        File ".../lib/python3.7/runpy.py", line 193, in _run_module_as_main
            "__main__", mod_spec)
        <elided>
        File ".../lib/python3.7/inspect.py", line 2008, in wrap_value
            raise RuntimeError()
        RuntimeError

    I think the fix is fairly simple; one needs to replace

        module_name = getattr(obj, '__module__', None)

    in inspect.py::_signature_fromstr by

        module_name = (getattr(obj, '__module__', None)
                       or getattr(getattr(obj, '__objclass__'), '__module__', None))

    (This is a less general but simpler solution than https://bugs.python.org/issue23967.)

  2. anntzer
    added
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    on Aug 18, 2019
  3. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  4. skirpichev
    added a commit that references this issue on Feb 11, 2024

    pythongh-82062: correctly set module for built-in instance methods in…

    9e6fd0d
  5. skirpichev
    added a commit that references this issue on Feb 26, 2024

    pythongh-82062: correctly set module for built-in instance methods in…

    83d21b2
  6. serhiy-storchaka
    added this to Inspect issues 🔍on Apr 30, 2024
  7. serhiy-storchaka
    added a commit that references this issue on May 2, 2024

    gh-82062: Fix support of parameter defaults on methods in extension m…

    9789440
  8. serhiy-storchaka
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    3.13only security fixesonly security fixes
    and removed
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    on May 2, 2024
  9. serhiy-storchaka
    closed this as completedon May 2, 2024
  10. github-project-automation
    moved this to Done in Inspect issues 🔍on May 2, 2024
  11. SonicField
    added a commit that references this issue on May 8, 2024

    pythongh-82062: Fix support of parameter defaults on methods in exten…

    e5cba77
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

    3.13only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory

    Projects

    • Inspect issues 🔍
      Status
      Done
      Show more project fields

    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.