GeezerVison is showing github.com — extend types and exceptions only for genesis by youknowone · Pull Request #7316 · RustPython/RustPython
extend types and exceptions only for genesis
#7316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.rs
(53)
All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -181,7 +181,7 @@ pub(crate) fn impl_pyclass_impl(attr: PunctuatedNestedMeta, item: Item) -> Resul
},
parse_quote! {
fn __extend_py_class(
ctx: &::rustpython_vm::Context,
ctx: &'static ::rustpython_vm::Context,
class: &'static ::rustpython_vm::Py<::rustpython_vm::builtins::PyType>,
) {
#getset_impl
Expand Down
Expand Up
@@ -222,7 +222,7 @@ pub(crate) fn impl_pyclass_impl(attr: PunctuatedNestedMeta, item: Item) -> Resul
const TP_FLAGS: ::rustpython_vm::types::PyTypeFlags = #flags;
fn impl_extend_class(
ctx: &::rustpython_vm::Context,
ctx: &'static ::rustpython_vm::Context,
class: &'static ::rustpython_vm::Py<::rustpython_vm::builtins::PyType>,
) {
#impl_ty::__extend_py_class(ctx, class);
Expand Down
Expand Up
@@ -284,7 +284,7 @@ pub(crate) fn impl_pyclass_impl(attr: PunctuatedNestedMeta, item: Item) -> Resul
},
parse_quote! {
fn __extend_py_class(
ctx: &::rustpython_vm::Context,
ctx: &'static ::rustpython_vm::Context,
class: &'static ::rustpython_vm::Py<::rustpython_vm::builtins::PyType>,
) {
#getset_impl
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -810,7 +810,7 @@ impl Drop for PyAsyncGen {
}
}
pub fn init(ctx: &Context) {
pub fn init(ctx: &'static Context) {
PyAsyncGen::extend_class(ctx, ctx.types.async_generator);
PyAsyncGenASend::extend_class(ctx, ctx.types.async_generator_asend);
PyAsyncGenAThrow::extend_class(ctx, ctx.types.async_generator_athrow);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -182,7 +182,7 @@ impl Representable for PyBool {
}
}
pub(crate) fn init(context: &Context) {
pub(crate) fn init(context: &'static Context) {
PyBool::extend_class(context, context.types.bool_type);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -224,7 +224,7 @@ impl fmt::Debug for PyNativeMethod {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyNativeFunction::extend_class(context, context.types.builtin_function_or_method_type);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -67,7 +67,7 @@ impl PyPayload for PyByteArray {
}
/// Fill bytearray class methods dictionary.
pub(crate) fn init(context: &Context) {
pub(crate) fn init(context: &'static Context) {
PyByteArray::extend_class(context, context.types.bytearray_type);
PyByteArrayIterator::extend_class(context, context.types.bytearray_iterator_type);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -86,7 +86,7 @@ impl PyPayload for PyBytes {
}
}
pub(crate) fn init(context: &Context) {
pub(crate) fn init(context: &'static Context) {
PyBytes::extend_class(context, context.types.bytes_type);
PyBytesIterator::extend_class(context, context.types.bytes_iterator_type);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -28,6 +28,6 @@ impl Representable for PyCapsule {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyCapsule::extend_class(context, context.types.capsule_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -227,6 +227,6 @@ impl Representable for PyClassMethod {
}
}
pub(crate) fn init(context: &Context) {
pub(crate) fn init(context: &'static Context) {
PyClassMethod::extend_class(context, context.types.classmethod_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -1275,6 +1275,6 @@ impl<'a> LineTableReader<'a> {
}
}
pub fn init(ctx: &Context) {
pub fn init(ctx: &'static Context) {
PyCode::extend_class(ctx, ctx.types.code_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -89,7 +89,7 @@ impl PyObjectRef {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyComplex::extend_class(context, context.types.complex_type);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -247,7 +247,7 @@ impl Drop for PyCoroutine {
}
}
pub fn init(ctx: &Context) {
pub fn init(ctx: &'static Context) {
PyCoroutine::extend_class(ctx, ctx.types.coroutine_type);
PyCoroutineWrapper::extend_class(ctx, ctx.types.coroutine_wrapper_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -426,7 +426,7 @@ impl GetDescriptor for PyMemberDescriptor {
}
}
pub fn init(ctx: &Context) {
pub fn init(ctx: &'static Context) {
PyMemberDescriptor::extend_class(ctx, ctx.types.member_descriptor_type);
PyMethodDescriptor::extend_class(ctx, ctx.types.method_descriptor_type);
PyWrapper::extend_class(ctx, ctx.types.wrapper_descriptor_type);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -1362,7 +1362,7 @@ fn set_inner_number_or(a: &PyObject, b: &PyObject, vm: &VirtualMachine) -> PyRes
set_inner_number_op(a, b, |a, b| a.union(b, vm), vm)
}
pub(crate) fn init(context: &Context) {
pub(crate) fn init(context: &'static Context) {
PyDict::extend_class(context, context.types.dict_type);
PyDictKeys::extend_class(context, context.types.dict_keys_type);
PyDictKeyIterator::extend_class(context, context.types.dict_keyiterator_type);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -144,7 +144,7 @@ impl IterNext for PyReverseSequenceIterator {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyEnumerate::extend_class(context, context.types.enumerate_type);
PyReverseSequenceIterator::extend_class(context, context.types.reverse_iter_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -71,6 +71,6 @@ impl IterNext for PyFilter {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyFilter::extend_class(context, context.types.filter_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -480,6 +480,6 @@ pub(crate) fn get_value(obj: &PyObject) -> f64 {
}
#[rustfmt::skip] // to avoid line splitting
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyFloat::extend_class(context, context.types.float_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -423,7 +423,7 @@ pub(crate) mod stack_analysis {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
Frame::extend_class(context, context.types.frame_type);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -1219,7 +1219,7 @@ impl PyCell {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyFunction::extend_class(context, context.types.function_type);
PyBoundMethod::extend_class(context, context.types.bound_method_type);
PyCell::extend_class(context, context.types.cell_type);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -173,6 +173,6 @@ impl Drop for PyGenerator {
}
}
pub fn init(ctx: &Context) {
pub fn init(ctx: &'static Context) {
PyGenerator::extend_class(ctx, ctx.types.generator_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -739,7 +739,7 @@ pub fn subscript_generic(type_params: PyObjectRef, vm: &VirtualMachine) -> PyRes
generic_alias_class.call((generic_type, args.to_pyobject(vm)), vm)
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyGenericAlias::extend_class(context, context.types.generic_alias_type);
PyGenericAliasIterator::extend_class(context, context.types.generic_alias_iterator_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -157,6 +157,6 @@ impl Representable for PyGetSet {
}
}
pub(crate) fn init(context: &Context) {
pub(crate) fn init(context: &'static Context) {
PyGetSet::extend_class(context, context.types.getset_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -744,6 +744,6 @@ pub fn try_to_float(int: &BigInt, vm: &VirtualMachine) -> PyResult<f64> {
.ok_or_else(|| vm.new_overflow_error("int too large to convert to float"))
}
pub(crate) fn init(context: &Context) {
pub(crate) fn init(context: &'static Context) {
PyInt::extend_class(context, context.types.int_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -224,6 +224,6 @@ impl Representable for PyInterpolation {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyInterpolation::extend_class(context, context.types.interpolation_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -289,7 +289,7 @@ impl IterNext for PyCallableIterator {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PySequenceIterator::extend_class(context, context.types.iter_type);
PyCallableIterator::extend_class(context, context.types.callable_iterator);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -696,7 +696,7 @@ impl IterNext for PyListReverseIterator {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
let list_type = &context.types.list_type;
PyList::extend_class(context, list_type);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -70,6 +70,6 @@ impl IterNext for PyMap {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyMap::extend_class(context, context.types.map_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -293,6 +293,6 @@ impl Representable for PyMappingProxy {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyMappingProxy::extend_class(context, context.types.mappingproxy_type)
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -1127,7 +1127,7 @@ impl Representable for PyMemoryView {
}
}
pub(crate) fn init(ctx: &Context) {
pub(crate) fn init(ctx: &'static Context) {
PyMemoryView::extend_class(ctx, ctx.types.memoryview_type);
PyMemoryViewIterator::extend_class(ctx, ctx.types.memoryviewiterator_type);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -452,7 +452,7 @@ impl Representable for PyModule {
}
}
pub(crate) fn init(context: &Context) {
pub(crate) fn init(context: &'static Context) {
PyModule::extend_class(context, context.types.module_type);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -175,6 +175,6 @@ impl Representable for PyNamespace {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyNamespace::extend_class(context, context.types.namespace_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -560,7 +560,7 @@ pub fn object_set_dict(obj: PyObjectRef, dict: PyDictRef, vm: &VirtualMachine) -
.map_err(|_| vm.new_attribute_error("This object has no __dict__"))
}
pub fn init(ctx: &Context) {
pub fn init(ctx: &'static Context) {
// Manually set init slot - derive macro doesn't generate extend_slots
// for trait impl that overrides #[pyslot] method
ctx.types
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -395,7 +395,7 @@ impl Initializer for PyProperty {
}
}
pub(crate) fn init(context: &Context) {
pub(crate) fn init(context: &'static Context) {
PyProperty::extend_class(context, context.types.property_type);
// This is a bit unfortunate, but this instance attribute overlaps with the
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -167,7 +167,7 @@ impl PyRange {
// obj.downcast_ref::<PyRange>().unwrap().clone()
// }
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyRange::extend_class(context, context.types.range_type);
PyLongRangeIterator::extend_class(context, context.types.long_range_iterator_type);
PyRangeIterator::extend_class(context, context.types.range_iterator_type);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -1421,7 +1421,7 @@ impl IterNext for PySetIterator {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PySet::extend_class(context, context.types.set_type);
PyFrozenSet::extend_class(context, context.types.frozenset_type);
PySetIterator::extend_class(context, context.types.set_iterator_type);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -132,7 +132,7 @@ impl Representable for PyNotImplemented {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyNone::extend_class(context, context.types.none_type);
PyNotImplemented::extend_class(context, context.types.not_implemented_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -354,7 +354,7 @@ impl Representable for PyEllipsis {
}
}
pub fn init(ctx: &Context) {
pub fn init(ctx: &'static Context) {
PySlice::extend_class(ctx, ctx.types.slice_type);
PyEllipsis::extend_class(ctx, ctx.types.ellipsis_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -197,6 +197,6 @@ impl Representable for PyStaticMethod {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyStaticMethod::extend_class(context, context.types.staticmethod_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -1761,7 +1761,7 @@ struct ReplaceArgs {
count: isize,
}
pub fn init(ctx: &Context) {
pub fn init(ctx: &'static Context) {
PyStr::extend_class(ctx, ctx.types.str_type);
PyStrIterator::extend_class(ctx, ctx.types.str_iterator_type);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -269,7 +269,7 @@ fn super_check(ty: PyTypeRef, obj: PyObjectRef, vm: &VirtualMachine) -> PyResult
)))
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
let super_type = &context.types.super_type;
PySuper::extend_class(context, super_type);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -329,7 +329,7 @@ impl IterNext for PyTemplateIter {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyTemplate::extend_class(context, context.types.template_type);
PyTemplateIter::extend_class(context, context.types.template_iter_type);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -119,7 +119,7 @@ impl PyTracebackRef {
}
}
pub fn init(context: &Context) {
pub fn init(context: &'static Context) {
PyTraceback::extend_class(context, context.types.traceback_type);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -583,7 +583,7 @@ impl IterNext for PyTupleIterator {
}
}
pub(crate) fn init(context: &Context) {
pub(crate) fn init(context: &'static Context) {
PyTuple::extend_class(context, context.types.tuple_type);
PyTupleIterator::extend_class(context, context.types.tuple_iterator_type);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -2103,7 +2103,7 @@ fn subtype_set_dict(obj: PyObjectRef, value: PyObjectRef, vm: &VirtualMachine) -
* The magical type type
*/
pub(crate) fn init(ctx: &Context) {
pub(crate) fn init(ctx: &'static Context) {
PyType::extend_class(ctx, ctx.types.type_type);
}
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.