diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-11-19 00:08:38 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-11-19 00:08:38 +0200 |
commit | 48ce2a82145e013ad4523410134a4f0517bc89d8 (patch) | |
tree | 9c3d4cf22b4a1cdbcf5c3c29ffc21554c334fe6c /Include | |
parent | fba4cbd2b544d0220290db721cc7f40ee8f49c36 (diff) | |
download | cpython-48ce2a82145e013ad4523410134a4f0517bc89d8.tar.gz |
Issue #22453: Warn against the use of leaking macro PyObject_REPR().
Diffstat (limited to 'Include')
-rw-r--r-- | Include/object.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Include/object.h b/Include/object.h index 7584d4cdde..93062889a7 100644 --- a/Include/object.h +++ b/Include/object.h @@ -572,8 +572,12 @@ PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *); PyAPI_FUNC(int) Py_ReprEnter(PyObject *); PyAPI_FUNC(void) Py_ReprLeave(PyObject *); -/* Helper for passing objects to printf and the like */ -#define PyObject_REPR(obj) _PyUnicode_AsString(PyObject_Repr(obj)) +#ifndef Py_LIMITED_API +/* Helper for passing objects to printf and the like. + Leaks refcounts. Don't use it! +*/ +#define PyObject_REPR(obj) PyUnicode_AsUTF8(PyObject_Repr(obj)) +#endif /* Flag bits for printing: */ #define Py_PRINT_RAW 1 /* No string quotes etc. */ |