From c62b43cae2abe3128f700b5bdf9640e0ee9a0968 Mon Sep 17 00:00:00 2001 From: GrieferAtWork Date: Fri, 10 Nov 2023 16:23:24 +0100 Subject: [PATCH] Implement `operator repr` for raw File objects --- src/deemon/objects/file.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/deemon/objects/file.c b/src/deemon/objects/file.c index a32c38a69..2f153b33d 100644 --- a/src/deemon/objects/file.c +++ b/src/deemon/objects/file.c @@ -3360,6 +3360,15 @@ file_shr(DeeObject *self, DeeObject *some_object) { return NULL; } +PRIVATE WUNUSED NONNULL((1)) DREF DeeStringObject *DCALL +file_repr(DeeObject *__restrict self) { + if (Dee_TYPE(self) == (DeeTypeObject *)&DeeFile_Type) + return (DREF DeeStringObject *)DeeString_New("File()"); + err_unimplemented_operator(Dee_TYPE(self), OPERATOR_REPR); + return NULL; +} + + PRIVATE struct type_math file_math = { /* .tp_int32 = */ NULL, /* .tp_int64 = */ NULL, @@ -3518,7 +3527,7 @@ PUBLIC DeeFileTypeObject DeeFile_Type = { }, /* .tp_cast = */ { /* .tp_str = */ NULL, - /* .tp_repr = */ NULL, + /* .tp_repr = */ (DREF DeeObject *(DCALL *)(DeeObject *__restrict))&file_repr, /* .tp_bool = */ NULL }, /* .tp_call = */ NULL,