Skip to content

Commit 5e4c3b0

Browse files
authored
gc is vm/stdlib (#6929)
1 parent fdf93c5 commit 5e4c3b0

4 files changed

Lines changed: 6 additions & 8 deletions

File tree

crates/stdlib/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ mod _asyncio;
1515
pub mod array;
1616
mod binascii;
1717
mod bisect;
18+
mod bz2;
1819
mod cmath;
20+
mod compression; // internal module
1921
mod contextvars;
2022
mod csv;
21-
mod gc;
22-
23-
mod bz2;
24-
mod compression; // internal module
2523
#[cfg(not(any(target_os = "android", target_arch = "wasm32")))]
2624
mod lzma;
2725
mod zlib;
@@ -126,7 +124,6 @@ pub fn stdlib_module_defs(ctx: &Context) -> Vec<&'static builtins::PyModuleDef>
126124
faulthandler::module_def(ctx),
127125
#[cfg(any(unix, target_os = "wasi"))]
128126
fcntl::module_def(ctx),
129-
gc::module_def(ctx),
130127
#[cfg(all(unix, not(any(target_os = "android", target_os = "redox"))))]
131128
grp::module_def(ctx),
132129
hashlib::module_def(ctx),

crates/vm/src/object/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ impl PyObject {
933933
/// Check if the object has been finalized (__del__ already called).
934934
/// _PyGC_FINALIZED in Py_GIL_DISABLED mode.
935935
#[inline]
936-
pub fn gc_finalized(&self) -> bool {
936+
pub(crate) fn gc_finalized(&self) -> bool {
937937
GcBits::from_bits_retain(self.0.gc_bits.load(Ordering::Relaxed)).contains(GcBits::FINALIZED)
938938
}
939939

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pub(crate) use gc::module_def;
22

33
#[pymodule]
44
mod gc {
5-
use crate::vm::{
5+
use crate::{
66
PyObjectRef, PyResult, VirtualMachine,
77
builtins::PyListRef,
88
function::{FuncArgs, OptionalArg},
@@ -205,7 +205,6 @@ mod gc {
205205
/// Return True if the object has been finalized by the garbage collector.
206206
#[pyfunction]
207207
fn is_finalized(obj: PyObjectRef) -> bool {
208-
// Check the per-object finalized flag directly
209208
obj.gc_finalized()
210209
}
211210

crates/vm/src/stdlib/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod codecs;
77
mod collections;
88
pub mod errno;
99
mod functools;
10+
mod gc;
1011
mod imp;
1112
pub mod io;
1213
mod itertools;
@@ -84,6 +85,7 @@ pub fn builtin_module_defs(ctx: &Context) -> Vec<&'static PyModuleDef> {
8485
ctypes::module_def(ctx),
8586
errno::module_def(ctx),
8687
functools::module_def(ctx),
88+
gc::module_def(ctx),
8789
imp::module_def(ctx),
8890
io::module_def(ctx),
8991
itertools::module_def(ctx),

0 commit comments

Comments
 (0)