This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2014年01月18日 11:43 by serhiy.storchaka, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (14) | |||
|---|---|---|---|
| msg208394 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年01月18日 11:43 | |
With patch for the zlib module (issue20193) which uses the "unspecified" default value: $ ./python -m pydoc zlib Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/inspect.py", line 1997, in wrap_value value = eval(s, module_dict) File "<string>", line 1, in <module> NameError: name 'unspecified' is not defined During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/inspect.py", line 2000, in wrap_value value = eval(s, sys_module_dict) File "<string>", line 1, in <module> NameError: name 'unspecified' is not defined During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/runpy.py", line 189, in _run_module_as_main "__main__", mod_spec) File "/home/serhiy/py/cpython/Lib/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/serhiy/py/cpython/Lib/pydoc.py", line 2593, in <module> cli() File "/home/serhiy/py/cpython/Lib/pydoc.py", line 2558, in cli help.help(arg) File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1840, in help elif request: doc(request, 'Help on %s:', output=self._output) File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1578, in doc pager(render_doc(thing, title, forceload)) File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1571, in render_doc return title % desc + '\n\n' + renderer.document(object, name) File "/home/serhiy/py/cpython/Lib/pydoc.py", line 356, in document if inspect.ismodule(object): return self.docmodule(*args) File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1142, in docmodule contents.append(self.document(value, key, name)) File "/home/serhiy/py/cpython/Lib/pydoc.py", line 358, in document if inspect.isroutine(object): return self.docroutine(*args) File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1323, in docroutine signature = inspect.signature(object) File "/home/serhiy/py/cpython/Lib/inspect.py", line 1468, in signature return Signature.from_builtin(obj) File "/home/serhiy/py/cpython/Lib/inspect.py", line 2052, in from_builtin p(name, default) File "/home/serhiy/py/cpython/Lib/inspect.py", line 2038, in p default_node = RewriteSymbolics().visit(default_node) File "/home/serhiy/py/cpython/Lib/ast.py", line 245, in visit return visitor(node) File "/home/serhiy/py/cpython/Lib/inspect.py", line 2030, in visit_Name return wrap_value(node.id) File "/home/serhiy/py/cpython/Lib/inspect.py", line 2002, in wrap_value raise RuntimeError() RuntimeError |
|||
| msg208405 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2014年01月18日 17:40 | |
Just checking--that happens with current trunk? Revision 32f9e0ae23f7 or newer? |
|||
| msg208407 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年01月18日 17:49 | |
That happens with current trunk (revision 1469c4fde8cd) and a patch for zlib from issue20193 [1]. [1] http://bugs.python.org/file33523/zlib_clinic.patch |
|||
| msg208411 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2014年01月18日 19:30 | |
I just built from a new clone of trunk, and it works fine for me. I didn't see the exception you report--I get the documentation for zlib. Do you still get the error if you build from a new clone of the current trunk? |
|||
| msg208457 - (view) | Author: Berker Peksag (berker.peksag) * (Python committer) | Date: 2014年01月19日 07:06 | |
> I just built from a new clone of trunk, and it works fine for me. It works fine for me, too (revision 8f11493cf727). |
|||
| msg208466 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2014年01月19日 09:12 | |
Closing. Reopen it if you get a reproducible test case with a fresh checkout of trunk. |
|||
| msg208477 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年01月19日 13:23 | |
I just built from a new clone of trunk (last revision is d0e2437136f5), and I still get the error. |
|||
| msg208799 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年01月22日 13:05 | |
Seems this is related issue: >>> import zlib, inspect >>> zlib.compressobj.__text_signature__ '(level=Z_DEFAULT_COMPRESSION, method=DEFLATED, wbits=MAX_WBITS, memLevel=DEF_MEM_LEVEL, strategy=Z_DEFAULT_STRATEGY, zdict=None)' >>> str(inspect.signature(zlib.compressobj)) '(level=-1, method=8, wbits=15, memLevel=8, strategy=0, zdict=None)' help(zlib.compress) shows the '(bytes, level=-1)' signature. inspect.signature() evaluates default values and instead of expected named constant it outputs numeric value which is often implementation detail. |
|||
| msg208801 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2014年01月22日 13:11 | |
Yes, that is how it must work. This is symmetric with pure Python functions: >>> import inspect >>> import zlib >>> def foo(a=zlib.Z_DEFAULT_COMPRESSION): pass ... >>> str(inspect.signature(foo)) '(a=-1)' |
|||
| msg208802 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2014年01月22日 13:13 | |
I missed the detail that you were working with a patch applied. I suspect the problem is, you misspelled one of the expressions you provided as a default value. Try str(inspect.signature(x)) on every function you converted. I bet one of them will throw an exception. Yes this is error-prone. |
|||
| msg208805 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年01月22日 13:26 | |
> Yes, that is how it must work. This is symmetric with pure Python
functions:
This is because in pure Python functions we have no enough information. I
believe than origin expression is more useful in the help. Compare:
>>> import re, inspect
>>> p = re.compile('')
>>> p.match.__text_signature__
'(string, pos=0, endpos=sys.maxsize)'
>>> str(inspect.signature(p.match))
'(string, pos=0, endpos=2147483647)'
> I suspect the problem is, you misspelled one of the expressions you provided
> as a default value.
>>> import zlib, inspect
>>> zlib.decompress.__text_signature__
'(data, wbits=unspecified, bufsize=unspecified)'
>>> str(inspect.signature(zlib.decompress))
Traceback (most recent call last):
File "/home/serhiy/py/cpython/Lib/inspect.py", line 1997, in wrap_value
value = eval(s, module_dict)
File "<string>", line 1, in <module>
NameError: name 'unspecified' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/serhiy/py/cpython/Lib/inspect.py", line 2000, in wrap_value
value = eval(s, sys_module_dict)
File "<string>", line 1, in <module>
NameError: name 'unspecified' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/serhiy/py/cpython/Lib/inspect.py", line 1468, in signature
return Signature.from_builtin(obj)
File "/home/serhiy/py/cpython/Lib/inspect.py", line 2052, in from_builtin
p(name, default)
File "/home/serhiy/py/cpython/Lib/inspect.py", line 2038, in p
default_node = RewriteSymbolics().visit(default_node)
File "/home/serhiy/py/cpython/Lib/ast.py", line 245, in visit
return visitor(node)
File "/home/serhiy/py/cpython/Lib/inspect.py", line 2030, in visit_Name
return wrap_value(node.id)
File "/home/serhiy/py/cpython/Lib/inspect.py", line 2002, in wrap_value
raise RuntimeError()
RuntimeError
|
|||
| msg208806 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2014年01月22日 13:41 | |
> This is because in pure Python functions we have no enough > information. I believe than origin expression is more useful > in the help. That doesn't matter. inspect.Signature would have to change in order to provide the original expression, and it's not going to for 3.4. In zlib.decompress, remove the "= unspecified". You can have a c_default without a default value now. |
|||
| msg208807 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年01月22日 13:52 | |
Without the "= unspecified" parameters will be non-optional. |
|||
| msg209358 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年01月26日 22:07 | |
Since Argument Clinic no more supports "unspecified" default value, this issue can be closed. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:57 | admin | set | github: 64492 |
| 2014年01月26日 22:07:31 | serhiy.storchaka | set | status: open -> closed resolution: out of date messages: + msg209358 stage: resolved |
| 2014年01月26日 22:05:28 | serhiy.storchaka | unlink | issue20193 dependencies |
| 2014年01月23日 18:13:25 | serhiy.storchaka | set | nosy:
+ yselivanov |
| 2014年01月22日 13:52:34 | serhiy.storchaka | set | messages: + msg208807 |
| 2014年01月22日 13:41:49 | larry | set | messages: + msg208806 |
| 2014年01月22日 13:26:03 | serhiy.storchaka | set | messages: + msg208805 |
| 2014年01月22日 13:13:21 | larry | set | messages: + msg208802 |
| 2014年01月22日 13:11:10 | larry | set | messages: + msg208801 |
| 2014年01月22日 13:05:06 | serhiy.storchaka | set | messages: + msg208799 |
| 2014年01月19日 13:23:08 | serhiy.storchaka | set | status: closed -> open resolution: works for me -> (no value) messages: + msg208477 stage: resolved -> (no value) |
| 2014年01月19日 09:12:30 | larry | set | status: open -> closed resolution: works for me messages: + msg208466 stage: resolved |
| 2014年01月19日 07:06:37 | berker.peksag | set | nosy:
+ berker.peksag messages: + msg208457 |
| 2014年01月18日 19:30:03 | larry | set | messages: + msg208411 |
| 2014年01月18日 17:49:16 | serhiy.storchaka | set | messages: + msg208407 |
| 2014年01月18日 17:40:34 | larry | set | messages: + msg208405 |
| 2014年01月18日 11:47:48 | serhiy.storchaka | link | issue20193 dependencies |
| 2014年01月18日 11:43:18 | serhiy.storchaka | create | |