@@ -1939,7 +1939,6 @@ gc_get_freeze_count_impl(PyObject *module)
1939
1939
return gc_list_size (& gcstate -> permanent_generation .head );
1940
1940
}
1941
1941
1942
- #ifdef Py_IMMORTAL_INSTANCES
1943
1942
1944
1943
/*[clinic input]
1945
1944
gc.is_immortal -> bool
@@ -1954,10 +1953,15 @@ static int
1954
1953
gc_is_immortal_impl (PyObject * module , PyObject * instance )
1955
1954
/*[clinic end generated code: output=743a163cb6aaf384 input=815182ca5c5d81e4]*/
1956
1955
{
1956
+ #ifdef Py_IMMORTAL_INSTANCES
1957
1957
return _Py_IsImmortal (instance );
1958
+ #else
1959
+ return 0 ;
1960
+ #endif /* Py_IMMORTAL_INSTANCES */
1958
1961
}
1959
1962
1960
1963
1964
+ #ifdef Py_IMMORTAL_INSTANCES
1961
1965
static int
1962
1966
immortalize_object (PyObject * obj , PyObject * Py_UNUSED (ignored ))
1963
1967
{
@@ -1977,6 +1981,7 @@ immortalize_object(PyObject *obj, PyObject *Py_UNUSED(ignored))
1977
1981
}
1978
1982
return 0 ;
1979
1983
}
1984
+ #endif /* Py_IMMORTAL_INSTANCES */
1980
1985
1981
1986
/*[clinic input]
1982
1987
gc.immortalize_heap
@@ -1988,6 +1993,7 @@ static PyObject *
1988
1993
gc_immortalize_heap_impl (PyObject * module )
1989
1994
/*[clinic end generated code: output=a7bb85fe2e27e4ae input=ca1709e4667c0623]*/
1990
1995
{
1996
+ #ifdef Py_IMMORTAL_INSTANCES
1991
1997
PyGC_Head * gc , * list ;
1992
1998
PyThreadState * tstate = _PyThreadState_GET ();
1993
1999
GCState * gcstate = & tstate -> interp -> gc ;
@@ -2012,10 +2018,10 @@ gc_immortalize_heap_impl(PyObject *module)
2012
2018
Py_TYPE (FROM_GC (gc ))-> tp_traverse (
2013
2019
FROM_GC (gc ), (visitproc )immortalize_object , NULL );
2014
2020
}
2021
+ #endif /* Py_IMMORTAL_INSTANCES */
2015
2022
Py_RETURN_NONE ;
2016
2023
}
2017
2024
2018
- #endif /* Py_IMMORTAL_INSTANCES */
2019
2025
2020
2026
PyDoc_STRVAR (gc__doc__ ,
2021
2027
"This module provides access to the garbage collector for reference cycles.\n"
@@ -2035,10 +2041,8 @@ PyDoc_STRVAR(gc__doc__,
2035
2041
"is_finalized()
A41F
-- Returns true if a given object has been already finalized.\n"
2036
2042
"get_referrers() -- Return the list of objects that refer to an object.\n"
2037
2043
"get_referents() -- Return the list of objects that an object refers to.\n"
2038
- #ifdef Py_IMMORTAL_INSTANCES
2039
2044
"immortalize_heap() -- Immortalize all instances accessible through the GC roots.\n"
2040
2045
"is_immortal() -- Check if an object has been immortalized.\n"
2041
- #endif /* Py_IMMORTAL_INSTANCES */
2042
2046
"freeze() -- Freeze all tracked objects and ignore them for future collections.\n"
2043
2047
"unfreeze() -- Unfreeze all objects in the permanent generation.\n"
2044
2048
"get_freeze_count() -- Return the number of objects in the permanent generation.\n" );
@@ -2064,10 +2068,8 @@ static PyMethodDef GcMethods[] = {
2064
2068
GC_FREEZE_METHODDEF
2065
2069
GC_UNFREEZE_METHODDEF
2066
2070
GC_GET_FREEZE_COUNT_METHODDEF
2067
- #ifdef Py_IMMORTAL_INSTANCES
2068
2071
GC_IMMORTALIZE_HEAP_METHODDEF
2069
2072
GC_IS_IMMORTAL_METHODDEF
2070
- #endif
2071
2073
{NULL , NULL } /* Sentinel */
2072
2074
};
2073
2075
0 commit comments