- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
Issue32240
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 2017-12-07 11:21 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 4746 | merged | serhiy.storchaka, 2017-12-07 11:23 | |
| Messages (7) | |||
|---|---|---|---|
| msg307795 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-12-07 11:21 | |
The proposed PR replaces argument declarations "PyObject **args" with "PyObject * const *args". In many cases this can be a pointer to the internal array of the tuple object. It is not safe to change it. PyEval_EvalCodeEx() is the only public function affected by this change, but this change is backward compatible. All other affected code is a private C API. |
|||
| msg307796 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2017-12-07 11:31 | |
I hate this "obscure" C syntax "PyObject * const *args". Technically, is it possible to define it as a type with a better name to give more context where the type would be defined? For example, "PyConstObjectArray"? |
|||
| msg307798 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-12-07 12:17 | |
I don't like "PyConstObjectArray" or any other name. I will just obfuscate the C code. "PyObject * const *args" should be clear for every C programmer, but if I see "PyConstObjectArray" I need to search the definition of it in the header files. And it is easy to make a mistake by using "PyConstObjectArray *" instead of "PyConstObjectArray" since complex types usually are passed by pointer in C. If you prefer, "PyObject * const *args" can be written as "PyObject * const args[]". This is an identical syntax, but the latter form is used more rarely. |
|||
| msg307799 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-12-07 12:24 | |
This change is inspired by reviewing one PR in which an input array of PyObject* was modified inplace. Even if it was correct in that particular case, it looked unsafe (actually that code was wrong for other causes). Adding the const qualifier allows to distinguish input PyObject* array arguments from pointers to output PyObject* arguments. |
|||
| msg308076 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-12-11 22:07 | |
This can affect Cython which uses the "fast call" convention. |
|||
| msg308372 - (view) | Author: Stefan Behnel (scoder) * ![]() |
Date: 2017-12-15 10:07 | |
Seems ok from Cython side. Could be a bit difficult to make an actual use of this, but at least it shouldn't break anything. And it's a reasonable constraint to enforce. |
|||
| msg308381 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-12-15 11:11 | |
New changeset a5552f023e1d8cbafee1e51d316cc581deb2295f by Serhiy Storchaka in branch 'master': bpo-32240: Add the const qualifier to declarations of PyObject* array arguments. (#4746) https://github.com/python/cpython/commit/a5552f023e1d8cbafee1e51d316cc581deb2295f |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:55 | admin | set | github: 76421 |
| 2017-12-15 11:15:02 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2017-12-15 11:11:14 | serhiy.storchaka | set | messages: + msg308381 |
| 2017-12-15 10:07:08 | scoder | set | messages: + msg308372 |
| 2017-12-11 22:07:06 | serhiy.storchaka | set | nosy:
+ scoder messages: + msg308076 |
| 2017-12-07 12:24:50 | serhiy.storchaka | set | messages: + msg307799 |
| 2017-12-07 12:17:15 | serhiy.storchaka | set | messages: + msg307798 |
| 2017-12-07 11:31:29 | vstinner | set | messages: + msg307796 |
| 2017-12-07 11:23:50 | serhiy.storchaka | set | keywords:
+ patch stage: patch review pull_requests: + pull_request4649 |
| 2017-12-07 11:21:41 | serhiy.storchaka | create | |


