diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index cc67258954..d850d26ca4 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -2924,13 +2924,10 @@ def test_runtime_checkable_generic_non_protocol(self): @runtime_checkable class Foo[T]: ... - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_runtime_checkable_generic(self): - # @runtime_checkable - # class Foo[T](Protocol): - # def meth(self) -> T: ... - # pass + @runtime_checkable + class Foo[T](Protocol): + def meth(self) -> T: ... class Impl: def meth(self) -> int: ... @@ -2945,9 +2942,9 @@ def method(self) -> int: ... # TODO: RUSTPYTHON @unittest.expectedFailure def test_pep695_generics_can_be_runtime_checkable(self): - # @runtime_checkable - # class HasX(Protocol): - # x: int + @runtime_checkable + class HasX(Protocol): + x: int class Bar[T]: x: T @@ -2987,22 +2984,20 @@ def f(): self.assertIsInstance(f, HasCallProtocol) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_no_inheritance_from_nominal(self): class C: pass - # class BP(Protocol): pass + class BP(Protocol): pass - # with self.assertRaises(TypeError): - # class P(C, Protocol): - # pass - # with self.assertRaises(TypeError): - # class Q(Protocol, C): - # pass - # with self.assertRaises(TypeError): - # class R(BP, C, Protocol): - # pass + with self.assertRaises(TypeError): + class P(C, Protocol): + pass + with self.assertRaises(TypeError): + class Q(Protocol, C): + pass + with self.assertRaises(TypeError): + class R(BP, C, Protocol): + pass class D(BP, C): pass @@ -3014,7 +3009,7 @@ class E(C, BP): pass # TODO: RUSTPYTHON @unittest.expectedFailure def test_no_instantiation(self): - # class P(Protocol): pass + class P(Protocol): pass with self.assertRaises(TypeError): P() @@ -3042,16 +3037,14 @@ class CG(PG[T]): pass with self.assertRaises(TypeError): CG[int](42) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_protocol_defining_init_does_not_get_overridden(self): # check that P.__init__ doesn't get clobbered # see https://bugs.python.org/issue44807 - # class P(Protocol): - # x: int - # def __init__(self, x: int) -> None: - # self.x = x + class P(Protocol): + x: int + def __init__(self, x: int) -> None: + self.x = x class C: pass c = C() @@ -3478,9 +3471,9 @@ def __getattr__(self, attr): # TODO: RUSTPYTHON @unittest.expectedFailure def test_no_weird_caching_with_issubclass_after_isinstance_pep695(self): - # @runtime_checkable - # class Spam[T](Protocol): - # x: T + @runtime_checkable + class Spam[T](Protocol): + x: T class Eggs[T]: def __init__(self, x: T) -> None: diff --git a/compiler/codegen/src/compile.rs b/compiler/codegen/src/compile.rs index f74d8b33d4..5abec728d5 100644 --- a/compiler/codegen/src/compile.rs +++ b/compiler/codegen/src/compile.rs @@ -230,6 +230,7 @@ fn eprint_location(zelf: &Compiler<'_>) { } /// Better traceback for internal error +#[track_caller] fn unwrap_internal(zelf: &Compiler<'_>, r: InternalResult) -> T { if let Err(ref r_err) = r { eprintln!("=== CODEGEN PANIC INFO ==="); @@ -1705,11 +1706,6 @@ impl Compiler<'_> { func_flags |= bytecode::MakeFunctionFlags::CLOSURE; } - // Pop the special type params symbol table - if type_params.is_some() { - self.pop_symbol_table(); - } - self.emit_load_const(ConstantData::Code { code: Box::new(code), }); @@ -1728,6 +1724,11 @@ impl Compiler<'_> { }; self.compile_normal_call(call); + // Pop the special type params symbol table + if type_params.is_some() { + self.pop_symbol_table(); + } + self.apply_decorators(decorator_list); self.store_name(name) diff --git a/vm/src/builtins/memory.rs b/vm/src/builtins/memory.rs index 54e82bbd15..27eb80176b 100644 --- a/vm/src/builtins/memory.rs +++ b/vm/src/builtins/memory.rs @@ -636,7 +636,7 @@ impl PyMemoryView { #[pygetset] fn f_contiguous(&self, vm: &VirtualMachine) -> PyResult { - // TODO: fortain order + // TODO: column-major order self.try_not_released(vm) .map(|_| self.desc.ndim() <= 1 && self.desc.is_contiguous()) } diff --git a/vm/src/protocol/buffer.rs b/vm/src/protocol/buffer.rs index 60f7c9ab44..0770cb5a83 100644 --- a/vm/src/protocol/buffer.rs +++ b/vm/src/protocol/buffer.rs @@ -381,7 +381,7 @@ impl BufferDescriptor { self.dim_desc.iter().any(|(shape, _, _)| *shape == 0) } - // TODO: support fortain order + // TODO: support column-major order } pub trait BufferResizeGuard {