diff --git a/derive/src/pyclass.rs b/derive/src/pyclass.rs index 9df92d5df9..4302608194 100644 --- a/derive/src/pyclass.rs +++ b/derive/src/pyclass.rs @@ -596,7 +596,7 @@ pub fn impl_pystruct_sequence(attr: AttributeArgs, item: Item) -> Result Result> { - self.inner()._optional_str("module") + const KEY: &str = "module"; + let inner = self.inner(); + let value = if let Some((_, meta)) = inner.meta.get(KEY) { + match meta { + Meta::NameValue(syn::MetaNameValue { + lit: syn::Lit::Str(lit), + .. + }) => Ok(Some(lit.value())), + Meta::NameValue(syn::MetaNameValue { + lit: syn::Lit::Bool(lit), + .. + }) => if lit.value { + Err(lit.span()) + } else { + Ok(None) + } + other => Err(other.span()), + } + } else { + Err(inner.ident.span()) + }.map_err(|span| syn::Error::new( + span, + format!( + "#[{attr_name}(module = ...)] must exist as a string or false. Try #[{attr_name}(module=false)] for built-in types.", + attr_name=inner.parent_type + ), + ))?; + Ok(value) + } + + pub fn mandatory_module(&self) -> Result { + let inner = self.inner(); + let value = self.module().ok().flatten(). + ok_or_else(|| syn::Error::new_spanned( + &inner.ident, + format!( + "#[{attr_name}(module = ...)] must exist as a string. Built-in module is not allowed here.", + attr_name=inner.parent_type + ), + ))?; + Ok(value) } } diff --git a/vm/src/exceptions.rs b/vm/src/exceptions.rs index 6cf1d8f29f..f1bebec9df 100644 --- a/vm/src/exceptions.rs +++ b/vm/src/exceptions.rs @@ -21,7 +21,7 @@ use std::io::{self, BufRead, BufReader}; use crossbeam_utils::atomic::AtomicCell; -#[pyclass(name = "BaseException")] +#[pyclass(module = false, name = "BaseException")] pub struct PyBaseException { traceback: PyRwLock>, cause: PyRwLock>, diff --git a/vm/src/frame.rs b/vm/src/frame.rs index 263096ca34..0fcc8fd956 100644 --- a/vm/src/frame.rs +++ b/vm/src/frame.rs @@ -87,7 +87,7 @@ struct FrameState { blocks: Vec, } -#[pyclass(name = "frame")] +#[pyclass(module = false, name = "frame")] pub struct Frame { pub code: PyCodeRef, pub scope: Scope, diff --git a/vm/src/obj/objasyncgenerator.rs b/vm/src/obj/objasyncgenerator.rs index 740c17d2fb..2dd744ade4 100644 --- a/vm/src/obj/objasyncgenerator.rs +++ b/vm/src/obj/objasyncgenerator.rs @@ -9,7 +9,7 @@ use crate::vm::VirtualMachine; use crossbeam_utils::atomic::AtomicCell; -#[pyclass(name = "async_generator")] +#[pyclass(name = "async_generator", module = false)] #[derive(Debug)] pub struct PyAsyncGen { inner: Coro, @@ -114,7 +114,7 @@ impl PyAsyncGen { } } -#[pyclass(name = "async_generator_wrapped_value")] +#[pyclass(module = false, name = "async_generator_wrapped_value")] #[derive(Debug)] pub(crate) struct PyAsyncGenWrappedValue(pub PyObjectRef); impl PyValue for PyAsyncGenWrappedValue { @@ -158,7 +158,7 @@ enum AwaitableState { Closed, } -#[pyclass(name = "async_generator_asend")] +#[pyclass(module = false, name = "async_generator_asend")] #[derive(Debug)] pub(crate) struct PyAsyncGenASend { ag: PyAsyncGenRef, @@ -253,7 +253,7 @@ impl PyAsyncGenASend { } } -#[pyclass(name = "async_generator_athrow")] +#[pyclass(module = false, name = "async_generator_athrow")] #[derive(Debug)] pub(crate) struct PyAsyncGenAThrow { ag: PyAsyncGenRef, diff --git a/vm/src/obj/objbool.rs b/vm/src/obj/objbool.rs index 3fac7ae6ab..fd9e29c848 100644 --- a/vm/src/obj/objbool.rs +++ b/vm/src/obj/objbool.rs @@ -81,7 +81,7 @@ pub fn boolval(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult { /// Returns True when the argument x is true, False otherwise. /// The builtins True and False are the only two instances of the class bool. /// The class bool is a subclass of the class int, and cannot be subclassed. -#[pyclass(name = "bool")] +#[pyclass(name = "bool", module = false)] pub(crate) struct PyBool; #[pyimpl] diff --git a/vm/src/obj/objbuiltinfunc.rs b/vm/src/obj/objbuiltinfunc.rs index a2dfe57ef7..8bb4cf457f 100644 --- a/vm/src/obj/objbuiltinfunc.rs +++ b/vm/src/obj/objbuiltinfunc.rs @@ -9,7 +9,7 @@ use crate::pyobject::{ use crate::slots::{SlotCall, SlotDescriptor}; use crate::vm::VirtualMachine; -#[pyclass(name = "builtin_function_or_method")] +#[pyclass(name = "builtin_function_or_method", module = false)] pub struct PyBuiltinFunction { value: PyNativeFunc, module: Option, @@ -70,7 +70,7 @@ impl PyBuiltinFunction { } } -#[pyclass(name = "method_descriptor")] +#[pyclass(module = false, name = "method_descriptor")] pub struct PyBuiltinMethod { function: PyBuiltinFunction, } diff --git a/vm/src/obj/objbytearray.rs b/vm/src/obj/objbytearray.rs index 4f27766186..0d6cd8f2e1 100644 --- a/vm/src/obj/objbytearray.rs +++ b/vm/src/obj/objbytearray.rs @@ -33,7 +33,7 @@ use crate::vm::VirtualMachine; /// - a bytes or a buffer object\n \ /// - any object implementing the buffer API.\n \ /// - an integer"; -#[pyclass(name = "bytearray")] +#[pyclass(module = false, name = "bytearray")] #[derive(Debug)] pub struct PyByteArray { inner: PyRwLock, @@ -606,7 +606,7 @@ impl PyByteArray { // obj.borrow_mut().kind = PyObjectPayload::Bytes { value }; // } -#[pyclass(name = "bytearray_iterator")] +#[pyclass(module = false, name = "bytearray_iterator")] #[derive(Debug)] pub struct PyByteArrayIterator { position: AtomicCell, diff --git a/vm/src/obj/objbytes.rs b/vm/src/obj/objbytes.rs index 2519b29912..5b44da6b24 100644 --- a/vm/src/obj/objbytes.rs +++ b/vm/src/obj/objbytes.rs @@ -32,7 +32,7 @@ use rustpython_common::hash::PyHash; /// - a text string encoded using the specified encoding\n \ /// - any object implementing the buffer API.\n \ /// - an integer"; -#[pyclass(name = "bytes")] +#[pyclass(module = false, name = "bytes")] #[derive(Clone, Debug)] pub struct PyBytes { inner: PyBytesInner, @@ -488,7 +488,7 @@ impl PyBytes { } } -#[pyclass(name = "bytes_iterator")] +#[pyclass(module = false, name = "bytes_iterator")] #[derive(Debug)] pub struct PyBytesIterator { position: AtomicCell, diff --git a/vm/src/obj/objclassmethod.rs b/vm/src/obj/objclassmethod.rs index 440cf63eba..edffe59872 100644 --- a/vm/src/obj/objclassmethod.rs +++ b/vm/src/obj/objclassmethod.rs @@ -26,7 +26,7 @@ use crate::vm::VirtualMachine; /// /// Class methods are different than C++ or Java static methods. /// If you want those, see the staticmethod builtin. -#[pyclass(name = "classmethod")] +#[pyclass(module = false, name = "classmethod")] #[derive(Clone, Debug)] pub struct PyClassMethod { callable: PyObjectRef, diff --git a/vm/src/obj/objcode.rs b/vm/src/obj/objcode.rs index f3196b7adc..14772e07ff 100644 --- a/vm/src/obj/objcode.rs +++ b/vm/src/obj/objcode.rs @@ -12,7 +12,7 @@ use crate::vm::VirtualMachine; pub type PyCodeRef = PyRef; -#[pyclass(name = "code")] +#[pyclass(module = false, name = "code")] pub struct PyCode { pub code: bytecode::CodeObject, } diff --git a/vm/src/obj/objcomplex.rs b/vm/src/obj/objcomplex.rs index 6ce41459ed..93e7b59632 100644 --- a/vm/src/obj/objcomplex.rs +++ b/vm/src/obj/objcomplex.rs @@ -14,7 +14,7 @@ use rustpython_common::{float_ops, hash}; /// Create a complex number from a real part and an optional imaginary part. /// /// This is equivalent to (real + imag*1j) where imag defaults to 0. -#[pyclass(name = "complex")] +#[pyclass(module = false, name = "complex")] #[derive(Debug, Copy, Clone, PartialEq)] pub struct PyComplex { value: Complex64, diff --git a/vm/src/obj/objcoroutine.rs b/vm/src/obj/objcoroutine.rs index d1faacc2be..35cc43a612 100644 --- a/vm/src/obj/objcoroutine.rs +++ b/vm/src/obj/objcoroutine.rs @@ -9,7 +9,7 @@ use crate::vm::VirtualMachine; pub type PyCoroutineRef = PyRef; -#[pyclass(name = "coroutine")] +#[pyclass(module = false, name = "coroutine")] #[derive(Debug)] pub struct PyCoroutine { inner: Coro, @@ -95,7 +95,7 @@ impl PyCoroutine { } } -#[pyclass(name = "coroutine_wrapper")] +#[pyclass(module = false, name = "coroutine_wrapper")] #[derive(Debug)] pub struct PyCoroutineWrapper { coro: PyCoroutineRef, diff --git a/vm/src/obj/objdict.rs b/vm/src/obj/objdict.rs index 7b46aec798..5e034bddb3 100644 --- a/vm/src/obj/objdict.rs +++ b/vm/src/obj/objdict.rs @@ -18,7 +18,7 @@ use std::mem::size_of; pub type DictContentType = dictdatatype::Dict; -#[pyclass(name = "dict")] +#[pyclass(module = false, name = "dict")] #[derive(Default)] pub struct PyDict { entries: DictContentType, @@ -553,7 +553,7 @@ impl Iterator for DictIter { macro_rules! dict_iterator { ( $name: ident, $iter_name: ident, $class: ident, $iter_class: ident, $class_name: literal, $iter_class_name: literal, $result_fn: expr) => { - #[pyclass(name = $class_name)] + #[pyclass(module=false,name = $class_name)] #[derive(Debug)] pub(crate) struct $name { pub dict: PyDictRef, @@ -598,7 +598,7 @@ macro_rules! dict_iterator { } } - #[pyclass(name = $iter_class_name)] + #[pyclass(module=false,name = $iter_class_name)] #[derive(Debug)] pub(crate) struct $iter_name { pub dict: PyDictRef, diff --git a/vm/src/obj/objellipsis.rs b/vm/src/obj/objellipsis.rs index ea61b933c8..7c97b92480 100644 --- a/vm/src/obj/objellipsis.rs +++ b/vm/src/obj/objellipsis.rs @@ -6,7 +6,7 @@ pub(crate) fn init(context: &PyContext) { PyEllipsis::extend_class(context, &context.ellipsis_type()); } -#[pyclass(name = "EllipsisType")] +#[pyclass(module = false, name = "EllipsisType")] #[derive(Debug)] pub struct PyEllipsis; diff --git a/vm/src/obj/objenumerate.rs b/vm/src/obj/objenumerate.rs index 3589ea5014..d699ce8f4d 100644 --- a/vm/src/obj/objenumerate.rs +++ b/vm/src/obj/objenumerate.rs @@ -11,7 +11,7 @@ use crate::function::OptionalArg; use crate::pyobject::{BorrowValue, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue}; use crate::vm::VirtualMachine; -#[pyclass(name = "enumerate")] +#[pyclass(module = false, name = "enumerate")] #[derive(Debug)] pub struct PyEnumerate { counter: PyRwLock, diff --git a/vm/src/obj/objfilter.rs b/vm/src/obj/objfilter.rs index 07774d8417..f8cf51e47d 100644 --- a/vm/src/obj/objfilter.rs +++ b/vm/src/obj/objfilter.rs @@ -10,7 +10,7 @@ pub type PyFilterRef = PyRef; /// /// Return an iterator yielding those items of iterable for which function(item) /// is true. If function is None, return the items that are true. -#[pyclass(name = "filter")] +#[pyclass(module = false, name = "filter")] #[derive(Debug)] pub struct PyFilter { predicate: PyObjectRef, diff --git a/vm/src/obj/objfloat.rs b/vm/src/obj/objfloat.rs index eca8399105..b61eb69304 100644 --- a/vm/src/obj/objfloat.rs +++ b/vm/src/obj/objfloat.rs @@ -19,7 +19,7 @@ use crate::vm::VirtualMachine; use rustpython_common::{float_ops, hash}; /// Convert a string or number to a floating point number, if possible. -#[pyclass(name = "float")] +#[pyclass(module = false, name = "float")] #[derive(Debug, Copy, Clone, PartialEq)] pub struct PyFloat { value: f64, diff --git a/vm/src/obj/objfunction.rs b/vm/src/obj/objfunction.rs index c07267b6b4..bdf845cdb9 100644 --- a/vm/src/obj/objfunction.rs +++ b/vm/src/obj/objfunction.rs @@ -20,7 +20,7 @@ use itertools::Itertools; pub type PyFunctionRef = PyRef; -#[pyclass(name = "function")] +#[pyclass(module = false, name = "function")] #[derive(Debug)] pub struct PyFunction { code: PyCodeRef, @@ -287,7 +287,7 @@ impl PyFunction { } } -#[pyclass(name = "method")] +#[pyclass(module = false, name = "method")] #[derive(Debug)] pub struct PyBoundMethod { // TODO: these shouldn't be public diff --git a/vm/src/obj/objgenerator.rs b/vm/src/obj/objgenerator.rs index e91e24406c..1578a9ad15 100644 --- a/vm/src/obj/objgenerator.rs +++ b/vm/src/obj/objgenerator.rs @@ -12,7 +12,7 @@ use crate::vm::VirtualMachine; pub type PyGeneratorRef = PyRef; -#[pyclass(name = "generator")] +#[pyclass(module = false, name = "generator")] #[derive(Debug)] pub struct PyGenerator { inner: Coro, diff --git a/vm/src/obj/objgetset.rs b/vm/src/obj/objgetset.rs index b7c43358e5..af307d1eea 100644 --- a/vm/src/obj/objgetset.rs +++ b/vm/src/obj/objgetset.rs @@ -144,7 +144,7 @@ where } } -#[pyclass(name = "getset_descriptor")] +#[pyclass(module = false, name = "getset_descriptor")] pub struct PyGetSet { name: String, getter: Option, diff --git a/vm/src/obj/objint.rs b/vm/src/obj/objint.rs index 5632635390..9c2030025f 100644 --- a/vm/src/obj/objint.rs +++ b/vm/src/obj/objint.rs @@ -40,7 +40,7 @@ use rustpython_common::hash; /// Base 0 means to interpret the base from the string as an integer literal. /// >>> int('0b100', base=0) /// 4 -#[pyclass(name = "int")] +#[pyclass(module = false, name = "int")] #[derive(Debug)] pub struct PyInt { value: BigInt, diff --git a/vm/src/obj/objiter.rs b/vm/src/obj/objiter.rs index 080f5606fe..2f13b6a2cd 100644 --- a/vm/src/obj/objiter.rs +++ b/vm/src/obj/objiter.rs @@ -149,7 +149,7 @@ pub fn length_hint(vm: &VirtualMachine, iter: PyObjectRef) -> PyResult, @@ -222,7 +222,7 @@ pub fn seq_iter_method(obj: PyObjectRef) -> PySequenceIterator { PySequenceIterator::new_forward(obj) } -#[pyclass(name = "callable_iterator")] +#[pyclass(module = false, name = "callable_iterator")] #[derive(Debug)] pub struct PyCallableIterator { callable: PyCallable, diff --git a/vm/src/obj/objlist.rs b/vm/src/obj/objlist.rs index 577f8b3726..e6b5d11195 100644 --- a/vm/src/obj/objlist.rs +++ b/vm/src/obj/objlist.rs @@ -27,7 +27,7 @@ use crate::vm::{ReprGuard, VirtualMachine}; /// /// If no argument is given, the constructor creates a new empty list. /// The argument must be an iterable if specified. -#[pyclass(name = "list")] +#[pyclass(module = false, name = "list")] #[derive(Default)] pub struct PyList { elements: PyRwLock>, @@ -825,7 +825,7 @@ fn do_sort( Ok(()) } -#[pyclass(name = "list_iterator")] +#[pyclass(module = false, name = "list_iterator")] #[derive(Debug)] pub struct PyListIterator { pub position: AtomicCell, @@ -864,7 +864,7 @@ impl PyListIterator { } } -#[pyclass(name = "list_reverseiterator")] +#[pyclass(module = false, name = "list_reverseiterator")] #[derive(Debug)] pub struct PyListReverseIterator { pub position: AtomicCell, diff --git a/vm/src/obj/objmap.rs b/vm/src/obj/objmap.rs index d1b0aa6cc2..4df54f4d61 100644 --- a/vm/src/obj/objmap.rs +++ b/vm/src/obj/objmap.rs @@ -8,7 +8,7 @@ use crate::vm::VirtualMachine; /// /// Make an iterator that computes the function using arguments from /// each of the iterables. Stops when the shortest iterable is exhausted. -#[pyclass(name = "map")] +#[pyclass(module = false, name = "map")] #[derive(Debug)] pub struct PyMap { mapper: PyObjectRef, diff --git a/vm/src/obj/objmappingproxy.rs b/vm/src/obj/objmappingproxy.rs index dfc5799a21..2661ddd09f 100644 --- a/vm/src/obj/objmappingproxy.rs +++ b/vm/src/obj/objmappingproxy.rs @@ -9,7 +9,7 @@ use crate::pyobject::{ }; use crate::vm::VirtualMachine; -#[pyclass(name = "mappingproxy")] +#[pyclass(module = false, name = "mappingproxy")] #[derive(Debug)] pub struct PyMappingProxy { mapping: MappingProxyInner, diff --git a/vm/src/obj/objmemory.rs b/vm/src/obj/objmemory.rs index 75b9aff13c..b58b6b7177 100644 --- a/vm/src/obj/objmemory.rs +++ b/vm/src/obj/objmemory.rs @@ -6,7 +6,7 @@ use crate::pyobject::{ use crate::stdlib::array::PyArray; use crate::vm::VirtualMachine; -#[pyclass(name = "memoryview")] +#[pyclass(module = false, name = "memoryview")] #[derive(Debug)] pub struct PyMemoryView { obj_ref: PyObjectRef, diff --git a/vm/src/obj/objmodule.rs b/vm/src/obj/objmodule.rs index 2cf9883114..0a1c7b32ba 100644 --- a/vm/src/obj/objmodule.rs +++ b/vm/src/obj/objmodule.rs @@ -7,7 +7,7 @@ use crate::pyobject::{ }; use crate::vm::VirtualMachine; -#[pyclass(name = "module")] +#[pyclass(module = false, name = "module")] #[derive(Debug)] pub struct PyModule {} pub type PyModuleRef = PyRef; diff --git a/vm/src/obj/objnamespace.rs b/vm/src/obj/objnamespace.rs index ddf1f9feb3..3850f5a77a 100644 --- a/vm/src/obj/objnamespace.rs +++ b/vm/src/obj/objnamespace.rs @@ -6,7 +6,7 @@ use crate::vm::VirtualMachine; /// A simple attribute-based namespace. /// /// SimpleNamespace(**kwargs) -#[pyclass(name = "SimpleNamespace")] +#[pyclass(module = false, name = "SimpleNamespace")] #[derive(Debug)] pub struct PyNamespace; diff --git a/vm/src/obj/objnone.rs b/vm/src/obj/objnone.rs index 09ea8ce646..450ca9fd69 100644 --- a/vm/src/obj/objnone.rs +++ b/vm/src/obj/objnone.rs @@ -4,7 +4,7 @@ use crate::pyobject::{ }; use crate::vm::VirtualMachine; -#[pyclass(name = "NoneType")] +#[pyclass(module = false, name = "NoneType")] #[derive(Debug)] pub struct PyNone; pub type PyNoneRef = PyRef; diff --git a/vm/src/obj/objobject.rs b/vm/src/obj/objobject.rs index 085e3b8d5a..f1adbb1496 100644 --- a/vm/src/obj/objobject.rs +++ b/vm/src/obj/objobject.rs @@ -13,7 +13,7 @@ use crate::pyobject::{ use crate::vm::VirtualMachine; /// The most base type -#[pyclass(name = "object")] +#[pyclass(module = false, name = "object")] #[derive(Debug)] pub struct PyBaseObject; diff --git a/vm/src/obj/objproperty.rs b/vm/src/obj/objproperty.rs index dc3da6e6d3..0f5f12dc8b 100644 --- a/vm/src/obj/objproperty.rs +++ b/vm/src/obj/objproperty.rs @@ -43,7 +43,7 @@ use crate::vm::VirtualMachine; /// @x.deleter /// def x(self): /// del self._x -#[pyclass(name = "property")] +#[pyclass(module = false, name = "property")] #[derive(Debug)] pub struct PyProperty { getter: Option, diff --git a/vm/src/obj/objrange.rs b/vm/src/obj/objrange.rs index 4ee30d7383..3e4ae757bf 100644 --- a/vm/src/obj/objrange.rs +++ b/vm/src/obj/objrange.rs @@ -25,7 +25,7 @@ use rustpython_common::hash::PyHash; /// start defaults to 0, and stop is omitted! range(4) produces 0, 1, 2, 3. /// These are exactly the valid indices for a list of 4 elements. /// When step is given, it specifies the increment (or decrement). -#[pyclass(name = "range")] +#[pyclass(module = false, name = "range")] #[derive(Debug, Clone)] pub struct PyRange { pub start: PyIntRef, @@ -400,7 +400,7 @@ impl PyRange { } } -#[pyclass(name = "range_iterator")] +#[pyclass(module = false, name = "range_iterator")] #[derive(Debug)] pub struct PyRangeIterator { position: AtomicCell, diff --git a/vm/src/obj/objset.rs b/vm/src/obj/objset.rs index b721550bd5..9dfb0c60ca 100644 --- a/vm/src/obj/objset.rs +++ b/vm/src/obj/objset.rs @@ -21,7 +21,7 @@ pub type SetContentType = dictdatatype::Dict<()>; /// set(iterable) -> new set object /// /// Build an unordered collection of unique elements. -#[pyclass(name = "set")] +#[pyclass(module = false, name = "set")] #[derive(Default)] pub struct PySet { inner: PySetInner, @@ -32,7 +32,7 @@ pub type PySetRef = PyRef; /// frozenset(iterable) -> frozenset object /// /// Build an immutable unordered collection of unique elements. -#[pyclass(name = "frozenset")] +#[pyclass(module = false, name = "frozenset")] #[derive(Default)] pub struct PyFrozenSet { inner: PySetInner, @@ -824,7 +824,7 @@ struct SetSizeInfo { position: usize, } -#[pyclass(name = "set_iterator")] +#[pyclass(module = false, name = "set_iterator")] pub(crate) struct PySetIterator { dict: PyRc, size_info: crossbeam_utils::atomic::AtomicCell, diff --git a/vm/src/obj/objslice.rs b/vm/src/obj/objslice.rs index a48ddc40a2..78516cfa54 100644 --- a/vm/src/obj/objslice.rs +++ b/vm/src/obj/objslice.rs @@ -9,7 +9,7 @@ use crate::vm::VirtualMachine; use num_bigint::{BigInt, ToBigInt}; use num_traits::{One, Signed, Zero}; -#[pyclass(name = "slice")] +#[pyclass(module = false, name = "slice")] #[derive(Debug)] pub struct PySlice { pub start: Option, diff --git a/vm/src/obj/objstaticmethod.rs b/vm/src/obj/objstaticmethod.rs index 1a6b8329bd..ec031286a1 100644 --- a/vm/src/obj/objstaticmethod.rs +++ b/vm/src/obj/objstaticmethod.rs @@ -4,7 +4,7 @@ use crate::pyobject::{PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyVa use crate::slots::SlotDescriptor; use crate::vm::VirtualMachine; -#[pyclass(name = "staticmethod")] +#[pyclass(module = false, name = "staticmethod")] #[derive(Clone, Debug)] pub struct PyStaticMethod { pub callable: PyObjectRef, diff --git a/vm/src/obj/objstr.rs b/vm/src/obj/objstr.rs index 85c74e6310..0f78dcab4e 100644 --- a/vm/src/obj/objstr.rs +++ b/vm/src/obj/objstr.rs @@ -41,7 +41,7 @@ use rustpython_common::hash; /// or repr(object). /// encoding defaults to sys.getdefaultencoding(). /// errors defaults to 'strict'." -#[pyclass(name = "str")] +#[pyclass(module = false, name = "str")] #[derive(Debug)] pub struct PyString { value: String, @@ -102,7 +102,7 @@ impl TryIntoRef for &str { } } -#[pyclass(name = "str_iterator")] +#[pyclass(module = false, name = "str_iterator")] #[derive(Debug)] pub struct PyStringIterator { pub string: PyStringRef, @@ -135,7 +135,7 @@ impl PyStringIterator { } } -#[pyclass(name = "str_reverseiterator")] +#[pyclass(module = false, name = "str_reverseiterator")] #[derive(Debug)] pub struct PyStringReverseIterator { pub position: AtomicCell, diff --git a/vm/src/obj/objsuper.rs b/vm/src/obj/objsuper.rs index 70148cb85c..06171900e0 100644 --- a/vm/src/obj/objsuper.rs +++ b/vm/src/obj/objsuper.rs @@ -21,7 +21,7 @@ use itertools::Itertools; pub type PySuperRef = PyRef; -#[pyclass(name = "super")] +#[pyclass(module = false, name = "super")] #[derive(Debug)] pub struct PySuper { typ: PyClassRef, diff --git a/vm/src/obj/objtraceback.rs b/vm/src/obj/objtraceback.rs index b8c13f3320..18c062a4c1 100644 --- a/vm/src/obj/objtraceback.rs +++ b/vm/src/obj/objtraceback.rs @@ -3,7 +3,7 @@ use crate::obj::objtype::PyClassRef; use crate::pyobject::{PyClassImpl, PyContext, PyRef, PyValue}; use crate::vm::VirtualMachine; -#[pyclass(name = "traceback")] +#[pyclass(module = false, name = "traceback")] #[derive(Debug)] pub struct PyTraceback { pub next: Option, // TODO: Make mutable diff --git a/vm/src/obj/objtuple.rs b/vm/src/obj/objtuple.rs index 533b3661e8..cfaec4e2e3 100644 --- a/vm/src/obj/objtuple.rs +++ b/vm/src/obj/objtuple.rs @@ -18,7 +18,7 @@ use rustpython_common::hash::PyHash; /// tuple(iterable) -> tuple initialized from iterable's items /// /// If the argument is a tuple, the return value is the same object. -#[pyclass(name = "tuple")] +#[pyclass(module = false, name = "tuple")] pub struct PyTuple { elements: Vec, } @@ -255,7 +255,7 @@ impl PyTuple { } } -#[pyclass(name = "tuple_iterator")] +#[pyclass(module = false, name = "tuple_iterator")] #[derive(Debug)] pub struct PyTupleIterator { position: AtomicCell, diff --git a/vm/src/obj/objtype.rs b/vm/src/obj/objtype.rs index d2003b9ad4..ade7ffcc9f 100644 --- a/vm/src/obj/objtype.rs +++ b/vm/src/obj/objtype.rs @@ -24,7 +24,7 @@ use std::ops::Deref; /// type(object_or_name, bases, dict) /// type(object) -> the object's type /// type(name, bases, dict) -> a new type -#[pyclass(name = "type")] +#[pyclass(module = false, name = "type")] pub struct PyClass { pub name: String, pub base: Option, diff --git a/vm/src/obj/objweakproxy.rs b/vm/src/obj/objweakproxy.rs index 44f0fee64a..d0c382f9a3 100644 --- a/vm/src/obj/objweakproxy.rs +++ b/vm/src/obj/objweakproxy.rs @@ -4,7 +4,7 @@ use crate::function::OptionalArg; use crate::pyobject::{PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue}; use crate::vm::VirtualMachine; -#[pyclass(name = "weakproxy")] +#[pyclass(module = false, name = "weakproxy")] #[derive(Debug)] pub struct PyWeakProxy { weak: PyWeak, diff --git a/vm/src/obj/objweakref.rs b/vm/src/obj/objweakref.rs index f43ba28315..ab3740fcab 100644 --- a/vm/src/obj/objweakref.rs +++ b/vm/src/obj/objweakref.rs @@ -11,7 +11,7 @@ use rustpython_common::rc::{PyRc, PyWeak as Weak}; use crossbeam_utils::atomic::AtomicCell; -#[pyclass(name = "ref")] +#[pyclass(module = false, name = "ref")] #[derive(Debug)] pub struct PyWeak { referent: Weak>, diff --git a/vm/src/obj/objzip.rs b/vm/src/obj/objzip.rs index f107b2aba8..6ff877ea7d 100644 --- a/vm/src/obj/objzip.rs +++ b/vm/src/obj/objzip.rs @@ -6,7 +6,7 @@ use crate::vm::VirtualMachine; pub type PyZipRef = PyRef; -#[pyclass(name = "zip")] +#[pyclass(module = false, name = "zip")] #[derive(Debug)] pub struct PyZip { iterators: Vec,