mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
fix a bug
This commit is contained in:
parent
2d4cf81356
commit
0109829ad4
@ -242,6 +242,7 @@ FrameResult VM__run_top_frame(VM* self) {
|
|||||||
DISPATCH();
|
DISPATCH();
|
||||||
}
|
}
|
||||||
case OP_LOAD_CLASS_GLOBAL: {
|
case OP_LOAD_CLASS_GLOBAL: {
|
||||||
|
assert(self->__curr_class);
|
||||||
py_Name name = byte.arg;
|
py_Name name = byte.arg;
|
||||||
py_Ref tmp = py_getdict(self->__curr_class, name);
|
py_Ref tmp = py_getdict(self->__curr_class, name);
|
||||||
if(tmp) {
|
if(tmp) {
|
||||||
@ -902,6 +903,7 @@ FrameResult VM__run_top_frame(VM* self) {
|
|||||||
DISPATCH();
|
DISPATCH();
|
||||||
}
|
}
|
||||||
case OP_STORE_CLASS_ATTR: {
|
case OP_STORE_CLASS_ATTR: {
|
||||||
|
assert(self->__curr_class);
|
||||||
py_Name name = byte.arg;
|
py_Name name = byte.arg;
|
||||||
if(py_istype(TOP(), tp_function)) {
|
if(py_istype(TOP(), tp_function)) {
|
||||||
Function* ud = py_touserdata(TOP());
|
Function* ud = py_touserdata(TOP());
|
||||||
@ -912,6 +914,7 @@ FrameResult VM__run_top_frame(VM* self) {
|
|||||||
DISPATCH();
|
DISPATCH();
|
||||||
}
|
}
|
||||||
case OP_ADD_CLASS_ANNOTATION: {
|
case OP_ADD_CLASS_ANNOTATION: {
|
||||||
|
assert(self->__curr_class);
|
||||||
// [type_hint string]
|
// [type_hint string]
|
||||||
py_Type type = py_totype(self->__curr_class);
|
py_Type type = py_totype(self->__curr_class);
|
||||||
py_TypeInfo* ti = TypeList__get(&self->types, type);
|
py_TypeInfo* ti = TypeList__get(&self->types, type);
|
||||||
|
@ -137,7 +137,10 @@ void py_clearexc(py_StackRef p0) {
|
|||||||
vm->last_retval = *py_NIL;
|
vm->last_retval = *py_NIL;
|
||||||
vm->curr_exception = *py_NIL;
|
vm->curr_exception = *py_NIL;
|
||||||
vm->is_curr_exc_handled = false;
|
vm->is_curr_exc_handled = false;
|
||||||
vm->__curr_class = NULL;
|
|
||||||
|
/* Don't clear this, because StopIteration() may corrupt the class defination */
|
||||||
|
// vm->__curr_class = NULL;
|
||||||
|
|
||||||
vm->__curr_function = NULL;
|
vm->__curr_function = NULL;
|
||||||
if(p0) vm->stack.sp = p0;
|
if(p0) vm->stack.sp = p0;
|
||||||
}
|
}
|
||||||
|
@ -137,3 +137,9 @@ assert (g == 1), g
|
|||||||
|
|
||||||
assert list.__new__(list) == []
|
assert list.__new__(list) == []
|
||||||
assert a.__new__ == list.__new__
|
assert a.__new__ == list.__new__
|
||||||
|
|
||||||
|
|
||||||
|
class A:
|
||||||
|
x: list[int] = [i for i in range(1, 4)]
|
||||||
|
|
||||||
|
assert A.x == [1, 2, 3]
|
Loading…
x
Reference in New Issue
Block a user