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.

Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.11
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: iritkatriel, jdemeyer, lukasz.langa, pablogsal, petr.viktorin, vstinner
Priority: normal Keywords: patch

Created on 2021-08-09 18:58 by iritkatriel, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 27693 merged iritkatriel, 2021-08-09 19:03
PR 12607 jdemeyer, 2021-08-27 10:37
PR 20104 iritkatriel, 2021-08-27 10:38
Messages (8)
msg399285 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-08-09 18:58
The old trashcan macros - Py_TRASHCAN_SAFE_BEGIN/END are unsafe (see Issue40608).

They were removed from the limited C API in 3.9:

They should be removed altogether, in favour of Py_TRASHCAN_BEGIN/END. Since they are not documented, I think this would be done by changing the comment before their definition in Include/cpython/object.h.
msg399754 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-08-17 14:47
Following discussion on python-dev I added a compile-time deprecation warning.

With this, and after reverting PR27683 I get the warning below. The build succeeds and the tests pass.

% make -s -j2
Objects/frameobject.c:622:5: warning: 'UsingDeprecatedTrashcanMacro' is deprecated [-Wdeprecated-declarations]
./Include/cpython/object.h:545:9: note: expanded from macro 'Py_TRASHCAN_SAFE_BEGIN'
        UsingDeprecatedTrashcanMacro cond=1; \
./Include/cpython/object.h:542:1: note: 'UsingDeprecatedTrashcanMacro' has been explicitly marked deprecated here
Py_DEPRECATED(3.11) typedef int UsingDeprecatedTrashcanMacro;
./Include/pyport.h:509:54: note: expanded from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
msg399756 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-08-17 14:51
Link to python-dev thread:
msg399866 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-18 19:50
New changeset 31ee985db86c1339d00bd0d3cc1712019460670a by Irit Katriel in branch 'main':
bpo-44874: deprecate Py_TRASHCAN_SAFE_BEGIN and Py_TRASHCAN_SAFE_END (GH-27693)
msg400410 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-27 10:48
This isn't closed yet because we need a decision whether to issue warnings about Py_TRASHCAN_SAFE_BEGIN/END usage in 3.10 as well. This was suggested by Petr here:

I personally don't feel like it's worth going any further than 3.10: Python 3.8 is security fixes only at this point, we haven't received any reports from users about the breakage in 3.9 so far with 3.9.7 around the corner.

So the backport is up to Pablo: should we raise the compiler warning on 3.10 as well?
msg400414 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-08-27 11:13
I prefer to not backport this to 3.10 because technically we cannot introduce new deprecations in an rc and I don't want someone compiling with -Werror to crash between rcs.
msg400415 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-27 11:16
Thanks for your input, Pablo. In this case this can safely be closed.

Thank you Irit for finding this and providing the PR! ✨ 🍰 ✨
msg400600 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-08-30 13:39
Thanks Irit for making progress on this annoying old C API!
Date User Action Args
2022-04-11 14:59:48adminsetgithub: 89037
2021-08-30 13:39:03vstinnersetnosy: + vstinner
messages: + msg400600
2021-08-27 11:16:13lukasz.langasetmessages: + msg400415
2021-08-27 11:14:54lukasz.langasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-08-27 11:13:59pablogsalsetmessages: + msg400414
2021-08-27 10:48:52lukasz.langasetmessages: + msg400410
2021-08-27 10:38:23iritkatrielsetpull_requests: + pull_request26439
2021-08-27 10:37:44jdemeyersetnosy: + jdemeyer
pull_requests: + pull_request26438
2021-08-18 19:50:27lukasz.langasetmessages: + msg399866
2021-08-17 14:51:11iritkatrielsetmessages: + msg399756
2021-08-17 14:47:31iritkatrielsetnosy: + petr.viktorin
2021-08-17 14:47:06iritkatrielsetmessages: + msg399754
2021-08-09 19:03:52iritkatrielsetkeywords: + patch
stage: patch review
pull_requests: + pull_request26179
2021-08-09 19:03:16iritkatrielsetnosy: + lukasz.langa, pablogsal
2021-08-09 18:58:05iritkatrielcreate