Skip to content

Commit 2c53f55

Browse files
committed
Remove smelly _conversion_converter symbol
1 parent 76816a1 commit 2c53f55

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

Include/internal/pycore_interpolation.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ extern "C" {
1111

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

14-
extern int _conversion_converter(PyObject *arg, PyObject **conv);
15-
1614
extern PyTypeObject _PyInterpolation_Type;
1715

1816
PyAPI_FUNC(PyObject *) _PyInterpolation_FromStackRefSteal(_PyStackRef *values);

Objects/interpolationobject.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,18 @@
99

1010
#include "pycore_interpolation.h"
1111

12-
/*[clinic input]
13-
module templatelib
14-
[clinic start generated code]*/
15-
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=dbb2236a3de68808]*/
16-
17-
#include "clinic/interpolationobject.c.h"
18-
19-
/*[clinic input]
20-
class templatelib.Interpolation "interpolationobject *" "&_PyInterpolation_Type"
21-
[clinic start generated code]*/
22-
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=5b183514b4d7e5af]*/
23-
24-
int
12+
static int
2513
_conversion_converter(PyObject *arg, PyObject **conversion)
2614
{
2715
if (arg == Py_None) {
2816
return 1;
2917
}
3018

3119
if (!PyUnicode_Check(arg)) {
32-
_PyArg_BadArgument("Interpolation", "argument 'conversion'", "str", arg);
20+
PyErr_Format(PyExc_TypeError,
21+
"%.200s() %.200s must be %.50s, not %.50s",
22+
"Interpolation", "argument 'conversion'", "str",
23+
arg == Py_None ? "None" : Py_TYPE(arg)->tp_name);
3324
return 0;
3425
}
3526

@@ -45,6 +36,13 @@ _conversion_converter(PyObject *arg, PyObject **conversion)
4536
return 1;
4637
}
4738

39+
#include "clinic/interpolationobject.c.h"
40+
41+
/*[clinic input]
42+
class Interpolation "interpolationobject *" "&_PyInterpolation_Type"
43+
[clinic start generated code]*/
44+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=161c64a16f9c4544]*/
45+
4846
typedef struct {
4947
PyObject_HEAD
5048
PyObject *value;
@@ -55,7 +53,7 @@ typedef struct {
5553

5654
/*[clinic input]
5755
@classmethod
58-
templatelib.Interpolation.__new__ as interpolation_new
56+
Interpolation.__new__ as interpolation_new
5957
6058
value: object
6159
expression: object(subclass_of='&PyUnicode_Type')
@@ -67,7 +65,7 @@ static PyObject *
6765
interpolation_new_impl(PyTypeObject *type, PyObject *value,
6866
PyObject *expression, PyObject *conversion,
6967
PyObject *format_spec)
70-
/*[clinic end generated code: output=6488e288765bc1a9 input=0abc8e498fb744a7]*/
68+
/*[clinic end generated code: output=6488e288765bc1a9 input=d91711024068528c]*/
7169
{
7270
interpolationobject *self = (interpolationobject *) type->tp_alloc(type, 0);
7371
if (!self) {

0 commit comments

Comments
 (0)