mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
PyContext::new don't create a new context
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user