- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
➜
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.
| Author | vstinner |
|---|---|
| Recipients | larry, rhettinger, serhiy.storchaka, vstinner |
| Date | 2017-01-17.15:17:13 |
| SpamBayes Score | -1.0 |
| Marked as misclassified | Yes |
| Message-id | <1484666234.33.0.914406658402.issue29299@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
|---|
When a function has only positional arguments and at least one argument is optional, the expected signature is:
func(mandatory_arg1, mandatory_arg2[, optional_arg3[, optinal_arg4]])
For example, the signature of format() is inconsistent with its documentation.
Signature:
---
$ python3 -c 'help(format)'|cat
Help on built-in function format in module builtins:
format(value, format_spec='', /)
Return value.__format__(format_spec)
format_spec defaults to the empty string
---
Documentation:
---
.. function:: format(value[, format_spec])
---
Attached patch is a first attempt to fix the issue. The problem is that my heuristic to check if an argument is "optional" doesn't seem to work as expected in all cases. I chose to check if the C default is NULL.
The problem is that some functions defines a C default to NULL whereas the Python default is set to a different value and is correct.
Example with _io.FileIO.truncate:
/*[clinic input]
_io.FileIO.truncate
size as posobj: object = NULL
/
whereas the documentation says that the default is None:
.. method:: truncate(size=None)
It's easy to fix the default, but in this case my change doesn't fix the signature anymore since the C default is still NULL:
/*[clinic input]
_io.FileIO.truncate
size as posobj: object(c_default="NULL") = None
/
We need a different heuristic than C default is NULL, or we should fix functions where the heuristic fails. |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2017-01-17 15:17:14 | vstinner | set | recipients: + vstinner, rhettinger, larry, serhiy.storchaka |
| 2017-01-17 15:17:14 | vstinner | set | messageid: <1484666234.33.0.914406658402.issue29299@psf.upfronthosting.co.za> |
| 2017-01-17 15:17:14 | vstinner | link | issue29299 messages |
| 2017-01-17 15:17:14 | vstinner | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements
