]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #22453: Removed non-documented macro PyObject_REPR().
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 18 Nov 2014 21:34:33 +0000 (23:34 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 18 Nov 2014 21:34:33 +0000 (23:34 +0200)
Doc/whatsnew/3.5.rst
Include/object.h
Misc/NEWS
Python/compile.c

index e90f5fa5cbdf0d026d445176a3c4392624bdd15f..1e8d63951cc0f71506524e0e0e5038f76d57da83 100644 (file)
@@ -441,3 +441,7 @@ Changes in the C API
 
 * The :c:type:`PyMemAllocator` structure was renamed to
   :c:type:`PyMemAllocatorEx` and a new ``calloc`` field was added.
+
+* Removed non-documented macro :c:macro:`PyObject_REPR` which leaked references.
+  Use format character ``%R`` in :c:func:`PyUnicode_FromFormat`-like functions
+  to format the :func:`repr` of the object.
index f3c87ebd227109842789eb6ce27233a9b6e736d2..e348d61d1b0db75ba8b4c01af724a1f5fdcdc468 100644 (file)
@@ -575,9 +575,6 @@ 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))
-
 /* Flag bits for printing: */
 #define Py_PRINT_RAW    1       /* No string quotes etc. */
 
index b7fd7ad40958d5224b5af548fa96186379e79c40..3e07239cb968a71a9967d60bf4e86490fc9ecc22 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -1256,6 +1256,8 @@ Build
 C API
 -----
 
+- Issue #22453: Removed non-documented macro PyObject_REPR().
+
 - Issue #18395: Rename ``_Py_char2wchar()`` to :c:func:`Py_DecodeLocale`,
   rename ``_Py_wchar2char()`` to :c:func:`Py_EncodeLocale`, and document
   these functions.
index e46ec6cedaf05124ccbc4c6e6e4f7b16eefc3876..ac9decc1433cd1f83d0528bf10d030a6f405d6fb 100644 (file)
@@ -1414,12 +1414,12 @@ get_ref_type(struct compiler *c, PyObject *name)
         PyOS_snprintf(buf, sizeof(buf),
                       "unknown scope for %.100s in %.100s(%s)\n"
                       "symbols: %s\nlocals: %s\nglobals: %s",
-                      PyBytes_AS_STRING(name),
-                      PyBytes_AS_STRING(c->u->u_name),
-                      PyObject_REPR(c->u->u_ste->ste_id),
-                      PyObject_REPR(c->u->u_ste->ste_symbols),
-                      PyObject_REPR(c->u->u_varnames),
-                      PyObject_REPR(c->u->u_names)
+                      PyUnicode_AsUTF8(name),
+                      PyUnicode_AsUTF8(c->u->u_name),
+                      PyUnicode_AsUTF8(PyObject_Repr(c->u->u_ste->ste_id)),
+                      PyUnicode_AsUTF8(PyObject_Repr(c->u->u_ste->ste_symbols)),
+                      PyUnicode_AsUTF8(PyObject_Repr(c->u->u_varnames)),
+                      PyUnicode_AsUTF8(PyObject_Repr(c->u->u_names))
         );
         Py_FatalError(buf);
     }
@@ -1476,11 +1476,11 @@ compiler_make_closure(struct compiler *c, PyCodeObject *co, Py_ssize_t args, PyO
             fprintf(stderr,
                 "lookup %s in %s %d %d\n"
                 "freevars of %s: %s\n",
-                PyObject_REPR(name),
-                PyBytes_AS_STRING(c->u->u_name),
+                PyUnicode_AsUTF8(PyObject_Repr(name)),
+                PyUnicode_AsUTF8(c->u->u_name),
                 reftype, arg,
-                _PyUnicode_AsString(co->co_name),
-                PyObject_REPR(co->co_freevars));
+                PyUnicode_AsUTF8(co->co_name),
+                PyUnicode_AsUTF8(PyObject_Repr(co->co_freevars)));
             Py_FatalError("compiler_make_closure()");
         }
         ADDOP_I(c, LOAD_CLOSURE, arg);