Skip to content

Commit 95165ce

Browse files
committed
Dropped almost-no-op customized objects repr()
The default repr is enough: it prints <TypeName at 0xADDR> instead of <TypeName object at 0xADDR>. The only people being hurt by this change are the ones using doctests: they deserve it.
1 parent 669e787 commit 95165ce

File tree

10 files changed

+10
-72
lines changed

10 files changed

+10
-72
lines changed

psycopg/adapter_asis.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,6 @@ asis_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
149149
return type->tp_alloc(type, 0);
150150
}
151151

152-
static PyObject *
153-
asis_repr(asisObject *self)
154-
{
155-
return PyString_FromFormat("<psycopg2.extensions.AsIs object at %p>", self);
156-
}
157-
158152

159153
/* object type */
160154

@@ -170,7 +164,7 @@ PyTypeObject asisType = {
170164
0, /*tp_getattr*/
171165
0, /*tp_setattr*/
172166
0, /*tp_compare*/
173-
(reprfunc)asis_repr, /*tp_repr*/
167+
0, /*tp_repr*/
174168
0, /*tp_as_number*/
175169
0, /*tp_as_sequence*/
176170
0, /*tp_as_mapping*/

psycopg/adapter_binary.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,6 @@ binary_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
254254
return type->tp_alloc(type, 0);
255255
}
256256

257-
static PyObject *
258-
binary_repr(binaryObject *self)
259-
{
260-
return PyString_FromFormat("<psycopg2.extensions.Binary object at %p>", self);
261-
}
262257

263258
/* object type */
264259

@@ -274,7 +269,7 @@ PyTypeObject binaryType = {
274269
0, /*tp_getattr*/
275270
0, /*tp_setattr*/
276271
0, /*tp_compare*/
277-
(reprfunc)binary_repr, /*tp_repr*/
272+
0, /*tp_repr*/
278273
0, /*tp_as_number*/
279274
0, /*tp_as_sequence*/
280275
0, /*tp_as_mapping*/

psycopg/adapter_datetime.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,6 @@ pydatetime_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
214214
return type->tp_alloc(type, 0);
215215
}
216216

217-
static PyObject *
218-
pydatetime_repr(pydatetimeObject *self)
219-
{
220-
return PyString_FromFormat("<psycopg2._psycopg.datetime object at %p>",
221-
self);
222-
}
223217

224218
/* object type */
225219

@@ -235,7 +229,7 @@ PyTypeObject pydatetimeType = {
235229
0, /*tp_getattr*/
236230
0, /*tp_setattr*/
237231
0, /*tp_compare*/
238-
(reprfunc)pydatetime_repr, /*tp_repr*/
232+
0, /*tp_repr*/
239233
0, /*tp_as_number*/
240234
0, /*tp_as_sequence*/
241235
0, /*tp_as_mapping*/

psycopg/adapter_list.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,6 @@ list_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
215215
return type->tp_alloc(type, 0);
216216
}
217217

218-
static PyObject *
219-
list_repr(listObject *self)
220-
{
221-
return PyString_FromFormat("<psycopg2._psycopg.List object at %p>", self);
222-
}
223218

224219
/* object type */
225220

@@ -235,7 +230,7 @@ PyTypeObject listType = {
235230
0, /*tp_getattr*/
236231
0, /*tp_setattr*/
237232
0, /*tp_compare*/
238-
(reprfunc)list_repr, /*tp_repr*/
233+
0, /*tp_repr*/
239234
0, /*tp_as_number*/
240235
0, /*tp_as_sequence*/
241236
0, /*tp_as_mapping*/

psycopg/adapter_mxdatetime.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,6 @@ mxdatetime_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
205205
return type->tp_alloc(type, 0);
206206
}
207207

208-
static PyObject *
209-
mxdatetime_repr(mxdatetimeObject *self)
210-
{
211-
return PyString_FromFormat("<psycopg2._psycopg.MxDateTime object at %p>",
212-
self);
213-
}
214208

215209
/* object type */
216210

@@ -226,7 +220,7 @@ PyTypeObject mxdatetimeType = {
226220
0, /*tp_getattr*/
227221
0, /*tp_setattr*/
228222
0, /*tp_compare*/
229-
(reprfunc)mxdatetime_repr, /*tp_repr*/
223+
0, /*tp_repr*/
230224
0, /*tp_as_number*/
231225
0, /*tp_as_sequence*/
232226
0, /*tp_as_mapping*/

psycopg/adapter_pboolean.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,6 @@ pboolean_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
146146
return type->tp_alloc(type, 0);
147147
}
148148

149-
static PyObject *
150-
pboolean_repr(pbooleanObject *self)
151-
{
152-
return PyString_FromFormat("<psycopg2.extensions.Boolean object at %p>",
153-
self);
154-
}
155-
156149

157150
/* object type */
158151

@@ -168,7 +161,7 @@ PyTypeObject pbooleanType = {
168161
0, /*tp_getattr*/
169162
0, /*tp_setattr*/
170163
0, /*tp_compare*/
171-
(reprfunc)pboolean_repr, /*tp_repr*/
164+
0, /*tp_repr*/
172165
0, /*tp_as_number*/
173166
0, /*tp_as_sequence*/
174167
0, /*tp_as_mapping*/

psycopg/adapter_pdecimal.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,6 @@ pdecimal_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
202202
return type->tp_alloc(type, 0);
203203
}
204204

205-
static PyObject *
206-
pdecimal_repr(pdecimalObject *self)
207-
{
208-
return PyString_FromFormat("<psycopg2._psycopg.Decimal object at %p>",
209-
self);
210-
}
211-
212205

213206
/* object type */
214207

@@ -224,7 +217,7 @@ PyTypeObject pdecimalType = {
224217
0, /*tp_getattr*/
225218
0, /*tp_setattr*/
226219
0, /*tp_compare*/
227-
(reprfunc)pdecimal_repr, /*tp_repr*/
220+
0, /*tp_repr*/
228221
0, /*tp_as_number*/
229222
0, /*tp_as_sequence*/
230223
0, /*tp_as_mapping*/

psycopg/adapter_pfloat.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,6 @@ pfloat_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
175175
return type->tp_alloc(type, 0);
176176
}
177177

178-
static PyObject *
179-
pfloat_repr(pfloatObject *self)
180-
{
181-
return PyString_FromFormat("<psycopg2.extensions.Float object at %p>",
182-
self);
183-
}
184-
185178

186179
/* object type */
187180

@@ -197,7 +190,7 @@ PyTypeObject pfloatType = {
197190
0, /*tp_getattr*/
198191
0, /*tp_setattr*/
199192
0, /*tp_compare*/
200-
(reprfunc)pfloat_repr, /*tp_repr*/
193+
0, /*tp_repr*/
201194
0, /*tp_as_number*/
202195
0, /*tp_as_sequence*/
203196
0, /*tp_as_mapping*/

psycopg/adapter_pint.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,6 @@ pint_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
161161
return type->tp_alloc(type, 0);
162162
}
163163

164-
static PyObject *
165-
pint_repr(pintObject *self)
166-
{
167-
return PyString_FromFormat("<psycopg2.extensions.Int object at %p>",
168-
self);
169-
}
170-
171164

172165
/* object type */
173166

@@ -183,7 +176,7 @@ PyTypeObject pintType = {
183176
0, /*tp_getattr*/
184177
0, /*tp_setattr*/
185178
0, /*tp_compare*/
186-
(reprfunc)pint_repr, /*tp_repr*/
179+
0, /*tp_repr*/
187180
0, /*tp_as_number*/
188181
0, /*tp_as_sequence*/
189182
0, /*tp_as_mapping*/

psycopg/adapter_qstring.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,6 @@ qstring_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
242242
return type->tp_alloc(type, 0);
243243
}
244244

245-
static PyObject *
246-
qstring_repr(qstringObject *self)
247-
{
248-
return PyString_FromFormat(
249-
"<psycopg2.extensions.QuotedString object at %p>", self);
250-
}
251245

252246
/* object type */
253247

@@ -263,7 +257,7 @@ PyTypeObject qstringType = {
263257
0, /*tp_getattr*/
264258
0, /*tp_setattr*/
265259
0, /*tp_compare*/
266-
(reprfunc)qstring_repr, /*tp_repr*/
260+
0, /*tp_repr*/
267261
0, /*tp_as_number*/
268262
0, /*tp_as_sequence*/
269263
0, /*tp_as_mapping*/

0 commit comments

Comments
 (0)