Skip to content

Commit b0dbe27

Browse files
committed
Fix conversion converter for interpolation __new__
1 parent c8f22f0 commit b0dbe27

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Include/internal/pycore_interpolation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern "C" {
1111

1212
#include "pycore_stackref.h" // _PyStackRef
1313

14-
extern int _conversion_converter(PyObject *arg, PyObject **Py_UNUSED(unused));
14+
extern int _conversion_converter(PyObject *arg, PyObject **conv);
1515

1616
extern PyTypeObject _PyInterpolation_Type;
1717

Objects/interpolationobject.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class templatelib.Interpolation "interpolationobject *" "&_PyInterpolation_Type"
2222
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=5b183514b4d7e5af]*/
2323

2424
int
25-
_conversion_converter(PyObject *arg, PyObject **Py_UNUSED(unused))
25+
_conversion_converter(PyObject *arg, PyObject **conv)
2626
{
2727
if (arg == Py_None) {
2828
return 1;
@@ -34,13 +34,14 @@ _conversion_converter(PyObject *arg, PyObject **Py_UNUSED(unused))
3434
}
3535

3636
Py_ssize_t len;
37-
const char *conv = PyUnicode_AsUTF8AndSize(arg, &len);
38-
if (len != 1 || !(conv[0] == 'a' || conv[0] == 'r' || conv[0] == 's')) {
37+
const char *conv_str = PyUnicode_AsUTF8AndSize(arg, &len);
38+
if (len != 1 || !(conv_str[0] == 'a' || conv_str[0] == 'r' || conv_str[0] == 's')) {
3939
PyErr_SetString(PyExc_ValueError,
4040
"Interpolation() argument 'conv' must be one of 's', 'a' or 'r'");
4141
return 0;
4242
}
4343

44+
*conv = arg;
4445
return 1;
4546
}
4647

0 commit comments

Comments
 (0)