PyContext::new don't create a new context

This commit is contained in:
Jeong Yunwon
2022-04-14 03:57:36 +09:00
parent f78070525f
commit df1aa5add7
4 changed files with 9 additions and 14 deletions

View File

@@ -953,7 +953,7 @@ mod tests {
#[test]
fn test_linearise() {
let context = PyContext::new();
let context = PyContext::default();
let object = &context.types.object_type;
let type_type = &context.types.type_type;

View File

@@ -24,10 +24,8 @@ use crate::{
};
use num_bigint::BigInt;
use num_traits::ToPrimitive;
use std::any::Any;
use std::collections::HashMap;
use std::fmt;
use std::ops::Deref;
use std::{any::Any, collections::HashMap, fmt, ops::Deref};
/* Python objects and references.
Okay, so each python object itself is an class itself (PyObject). Each
@@ -143,12 +141,6 @@ impl PyContext {
exceptions::ExceptionZoo::extend(&context);
context
}
pub fn new() -> Self {
rustpython_common::static_cell! {
static CONTEXT: PyContext;
}
CONTEXT.get_or_init(Self::init).clone()
}
pub fn none(&self) -> PyObjectRef {
self.none.clone().into()
@@ -338,7 +330,10 @@ impl PyContext {
impl Default for PyContext {
fn default() -> Self {
PyContext::new()
rustpython_common::static_cell! {
static CONTEXT: PyContext;
}
CONTEXT.get_or_init(Self::init).clone()
}
}

View File

@@ -1177,7 +1177,7 @@ mod tests {
#[test]
fn miri_test_drop() {
let ctx = crate::PyContext::new();
let ctx = crate::PyContext::default();
let obj = ctx.new_bytes(b"dfghjkl".to_vec());
drop(obj);
}

View File

@@ -243,7 +243,7 @@ impl VirtualMachine {
/// Create a new `VirtualMachine` structure.
fn new(settings: PySettings) -> VirtualMachine {
flame_guard!("new VirtualMachine");
let ctx = PyContext::new();
let ctx = PyContext::default();
// make a new module without access to the vm; doesn't
// set __spec__, __loader__, etc. attributes