Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/vm/src/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ impl StringPool {
let cache = CachedPyStrRef { inner: s };
let mut inner = zelf.inner.write();
if inner.insert(cache.clone()) {
drop(inner);
let interned = unsafe { cache.as_interned_str() };
// `mark_intern` also makes the object immortal: the pool
// never gives an entry up and its refcount could already never
Expand All @@ -65,6 +64,8 @@ impl StringPool {
// read-modify-write off every incref and decref of an
// attribute name, a dict key or a docstring.
unsafe { interned.as_object().mark_intern() };
// Publish the interned flag before another lookup can return this entry.
drop(inner);
interned
} else {
unsafe {
Expand Down
5 changes: 5 additions & 0 deletions crates/vm/src/stdlib/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,11 @@ pub mod sys {
vm.ctx.intern_str(string).to_owned()
}

#[pyfunction]
fn _is_interned(string: PyRef<PyStr>) -> bool {
string.as_object().is_interned()
}

#[pyattr]
fn int_info(vm: &VirtualMachine) -> PyTupleRef {
PyIntInfo::from_data(IntInfoData::INFO, vm)
Expand Down
Loading