From 2ba088d8bba60db55bc8c74fcd8faa2b5e0f283b Mon Sep 17 00:00:00 2001 From: Stephan Hohe Date: Sat, 9 Mar 2019 15:15:02 +0100 Subject: [PATCH 1/4] Fix format string in MatchObject repr The `mark`s are Py_ssize_t, not `int`. The correct format specifier for that is %zd. --- Modules/_sre.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_sre.c b/Modules/_sre.c index 5cea7562f2807a..014cc546e345d9 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -2306,7 +2306,7 @@ match_repr(MatchObject *self) if (group0 == NULL) return NULL; result = PyUnicode_FromFormat( - "<%s object; span=(%d, %d), match=%.50R>", + "<%s object; span=(%zd, %zd), match=%.50R>", Py_TYPE(self)->tp_name, self->mark[0], self->mark[1], group0); Py_DECREF(group0); From 496648a5de03448ebf8e20fdf35d339f13f4b47d Mon Sep 17 00:00:00 2001 From: Stephan Hohe Date: Sat, 9 Mar 2019 15:29:05 +0100 Subject: [PATCH 2/4] Fix format string in StdPrinter repr The appropriate format specifier to print a pointer as 0x.... is %p. --- Objects/fileobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/fileobject.c b/Objects/fileobject.c index babaa05bdbc49e..39c7c109979a48 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -411,7 +411,7 @@ stdprinter_fileno(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored)) static PyObject * stdprinter_repr(PyStdPrinter_Object *self) { - return PyUnicode_FromFormat("", + return PyUnicode_FromFormat("", self->fd, self); } From ebbc37a371bd32c1e2046a4547e9c5014eb6d2ee Mon Sep 17 00:00:00 2001 From: Stephan Hohe Date: Sat, 9 Mar 2019 18:02:42 +0100 Subject: [PATCH 3/4] Add NEWS entry --- .../next/Library/2019-03-09-18-01-24.bpo-36251.zOp9l0.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2019-03-09-18-01-24.bpo-36251.zOp9l0.rst diff --git a/Misc/NEWS.d/next/Library/2019-03-09-18-01-24.bpo-36251.zOp9l0.rst b/Misc/NEWS.d/next/Library/2019-03-09-18-01-24.bpo-36251.zOp9l0.rst new file mode 100644 index 00000000000000..29319397b84089 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-03-09-18-01-24.bpo-36251.zOp9l0.rst @@ -0,0 +1,2 @@ +Fix format strings used for StdPrinter and MatchObject reprs. Patch by +Stephan Hohe. From 7acc92685dea3a4b326b97b7bcfa71b267b9a01c Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 10 Mar 2019 10:38:46 +0200 Subject: [PATCH 4/4] Update 2019-03-09-18-01-24.bpo-36251.zOp9l0.rst --- .../next/Library/2019-03-09-18-01-24.bpo-36251.zOp9l0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2019-03-09-18-01-24.bpo-36251.zOp9l0.rst b/Misc/NEWS.d/next/Library/2019-03-09-18-01-24.bpo-36251.zOp9l0.rst index 29319397b84089..5138b0a0cb8b01 100644 --- a/Misc/NEWS.d/next/Library/2019-03-09-18-01-24.bpo-36251.zOp9l0.rst +++ b/Misc/NEWS.d/next/Library/2019-03-09-18-01-24.bpo-36251.zOp9l0.rst @@ -1,2 +1,2 @@ -Fix format strings used for StdPrinter and MatchObject reprs. Patch by +Fix format strings used for stderrprinter and re.Match reprs. Patch by Stephan Hohe.