Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 04dbf3b

Browse files
committed
Kill all uses and definitions of tp_print under Objects/. (Others will follow.)
Finally kill intobject.c, which was #ifdef'ed out a long time ago.
1 parent d474ce8 commit 04dbf3b

11 files changed

Lines changed: 11 additions & 1470 deletions

Objects/boolobject.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@
33
#include "Python.h"
44
#include "longintrepr.h"
55

6-
/* We need to define bool_print to override int_print */
7-
8-
static int
9-
bool_print(PyObject *self, FILE *fp, int flags)
10-
{
11-
fputs(self == Py_False ? "False" : "True", fp);
12-
return 0;
13-
}
14-
156
/* We define bool_repr to return "False" or "True" */
167

178
static PyObject *false_str = NULL;
@@ -148,7 +139,7 @@ PyTypeObject PyBool_Type = {
148139
sizeof(struct _longobject),
149140
0,
150141
0, /* tp_dealloc */
151-
bool_print, /* tp_print */
142+
0, /* tp_print */
152143
0, /* tp_getattr */
153144
0, /* tp_setattr */
154145
0, /* tp_compare */

Objects/complexobject.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -327,16 +327,6 @@ complex_to_buf(char *buf, int bufsz, PyComplexObject *v, int precision)
327327
}
328328
}
329329

330-
static int
331-
complex_print(PyComplexObject *v, FILE *fp, int flags)
332-
{
333-
char buf[100];
334-
complex_to_buf(buf, sizeof(buf), v,
335-
(flags & Py_PRINT_RAW) ? PREC_STR : PREC_REPR);
336-
fputs(buf, fp);
337-
return 0;
338-
}
339-
340330
static PyObject *
341331
complex_repr(PyComplexObject *v)
342332
{
@@ -1005,7 +995,7 @@ PyTypeObject PyComplex_Type = {
1005995
sizeof(PyComplexObject),
1006996
0,
1007997
complex_dealloc, /* tp_dealloc */
1008-
(printfunc)complex_print, /* tp_print */
998+
0, /* tp_print */
1009999
0, /* tp_getattr */
10101000
0, /* tp_setattr */
10111001
0, /* tp_compare */

Objects/dictobject.c

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -886,51 +886,6 @@ dict_dealloc(register dictobject *mp)
886886
Py_TRASHCAN_SAFE_END(mp)
887887
}
888888

889-
static int
890-
dict_print(register dictobject *mp, register FILE *fp, register int flags)
891-
{
892-
register Py_ssize_t i;
893-
register Py_ssize_t any;
894-
int status;
895-
896-
status = Py_ReprEnter((PyObject*)mp);
897-
if (status != 0) {
898-
if (status < 0)
899-
return status;
900-
fprintf(fp, "{...}");
901-
return 0;
902-
}
903-
904-
fprintf(fp, "{");
905-
any = 0;
906-
for (i = 0; i <= mp->ma_mask; i++) {
907-
dictentry *ep = mp->ma_table + i;
908-
PyObject *pvalue = ep->me_value;
909-
if (pvalue != NULL) {
910-
/* Prevent PyObject_Repr from deleting value during
911-
key format */
912-
Py_INCREF(pvalue);
913-
if (any++ > 0)
914-
fprintf(fp, ", ");
915-
if (PyObject_Print((PyObject *)ep->me_key, fp, 0)!=0) {
916-
Py_DECREF(pvalue);
917-
Py_ReprLeave((PyObject*)mp);
918-
return -1;
919-
}
920-
fprintf(fp, ": ");
921-
if (PyObject_Print(pvalue, fp, 0) != 0) {
922-
Py_DECREF(pvalue);
923-
Py_ReprLeave((PyObject*)mp);
924-
return -1;
925-
}
926-
Py_DECREF(pvalue);
927-
}
928-
}
929-
fprintf(fp, "}");
930-
Py_ReprLeave((PyObject*)mp);
931-
return 0;
932-
}
933-
934889
static PyObject *
935890
dict_repr(dictobject *mp)
936891
{
@@ -1974,7 +1929,7 @@ PyTypeObject PyDict_Type = {
19741929
sizeof(dictobject),
19751930
0,
19761931
(destructor)dict_dealloc, /* tp_dealloc */
1977-
(printfunc)dict_print, /* tp_print */
1932+
0, /* tp_print */
19781933
0, /* tp_getattr */
19791934
0, /* tp_setattr */
19801935
0, /* tp_compare */

Objects/floatobject.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ format_double(char *buf, size_t buflen, double ob_fval, int precision)
205205
{
206206
register char *cp;
207207
char format[32];
208-
/* Subroutine for float_repr, float_str, float_print and others.
208+
/* Subroutine for float_repr, float_str, and others.
209209
We want float numbers to be recognizable as such,
210210
i.e., they should contain a decimal point or an exponent.
211211
However, %g may print the number as an integer;
@@ -286,17 +286,6 @@ convert_to_double(PyObject **v, double *dbl)
286286
#define PREC_REPR 17
287287
#define PREC_STR 12
288288

289-
/* ARGSUSED */
290-
static int
291-
float_print(PyFloatObject *v, FILE *fp, int flags)
292-
{
293-
char buf[100];
294-
format_float(buf, sizeof(buf), v,
295-
(flags & Py_PRINT_RAW) ? PREC_STR : PREC_REPR);
296-
fputs(buf, fp);
297-
return 0;
298-
}
299-
300289
static PyObject *
301290
float_repr(PyFloatObject *v)
302291
{
@@ -1058,7 +1047,7 @@ PyTypeObject PyFloat_Type = {
10581047
sizeof(PyFloatObject),
10591048
0,
10601049
(destructor)float_dealloc, /* tp_dealloc */
1061-
(printfunc)float_print, /* tp_print */
1050+
0, /* tp_print */
10621051
0, /* tp_getattr */
10631052
0, /* tp_setattr */
10641053
0, /* tp_compare */

0 commit comments

Comments
 (0)