[issue37881] __text_signature__ parser doesn't handle globals in extension module

2020-10-08 Thread Antoine Pitrou


Change by Antoine Pitrou :


--
nosy: +eric.snow

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37881] __text_signature__ parser doesn't handle globals in extension module

2020-03-30 Thread Eric Wieser


Change by Eric Wieser :


--
nosy: +Eric Wieser

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37881] __text_signature__ parser doesn't handle globals in extension module

2019-08-18 Thread Antony Lee


New submission from Antony Lee :

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 "", line 1, in 
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 "", line 1, in 
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)

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.)

--
components: Extension Modules
messages: 349919
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: __text_signature__ parser doesn't handle globals in extension module

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com