Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
8661036c
Kaydet (Commit)
8661036c
authored
Nis 10, 1998
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add implementations of Py_Repr{Enter,Leave}.
(Jeremy will hardly recognize his patch :-)
üst
26d4ac30
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
object.c
Objects/object.c
+64
-0
No files found.
Objects/object.c
Dosyayı görüntüle @
8661036c
...
@@ -790,3 +790,67 @@ PyMem_Free(p)
...
@@ -790,3 +790,67 @@ PyMem_Free(p)
{
{
free
(
p
);
free
(
p
);
}
}
/* These methods are used to control infinite recursion in repr, str, print,
etc. Container objects that may recursively contain themselves,
e.g. builtin dictionaries and lists, should used Py_ReprEnter() and
Py_ReprLeave() to avoid infinite recursion.
Py_ReprEnter() returns 0 the first time it is called for a particular
object and 1 every time thereafter. It returns -1 if an exception
occurred. Py_ReprLeave() has no return value.
See dictobject.c and listobject.c for examples of use.
*/
#define KEY "Py_Repr"
int
Py_ReprEnter
(
obj
)
PyObject
*
obj
;
{
PyObject
*
dict
;
PyObject
*
list
;
int
i
;
dict
=
PyThreadState_GetDict
();
if
(
dict
==
NULL
)
return
-
1
;
list
=
PyDict_GetItemString
(
dict
,
KEY
);
if
(
list
==
NULL
)
{
list
=
PyList_New
(
0
);
if
(
list
==
NULL
)
return
-
1
;
if
(
PyDict_SetItemString
(
dict
,
KEY
,
list
)
<
0
)
return
-
1
;
Py_DECREF
(
list
);
}
i
=
PyList_GET_SIZE
(
list
);
while
(
--
i
>=
0
)
{
if
(
PyList_GET_ITEM
(
list
,
i
)
==
obj
)
return
1
;
}
PyList_Append
(
list
,
obj
);
return
0
;
}
void
Py_ReprLeave
(
obj
)
PyObject
*
obj
;
{
PyObject
*
dict
;
PyObject
*
list
;
int
i
;
dict
=
PyThreadState_GetDict
();
list
=
PyDict_GetItemString
(
dict
,
KEY
);
i
=
PyList_GET_SIZE
(
list
);
/* Count backwards because we always expect obj to be list[-1] */
while
(
--
i
>=
0
)
{
if
(
PyList_GET_ITEM
(
list
,
i
)
==
obj
)
{
PyList_SetSlice
(
list
,
i
,
i
+
1
,
NULL
);
break
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment