summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/builtin.c10
-rw-r--r--py/obj.h2
-rw-r--r--py/objgenerator.c11
-rw-r--r--py/runtime.c2
4 files changed, 8 insertions, 17 deletions
diff --git a/py/builtin.c b/py/builtin.c
index 11e19fdea9..7d2cc72b77 100644
--- a/py/builtin.c
+++ b/py/builtin.c
@@ -11,7 +11,6 @@
#include "obj.h"
#include "runtime0.h"
#include "runtime.h"
-//#include "bc.h"
#include "map.h"
#include "builtin.h"
@@ -293,8 +292,13 @@ mp_obj_t mp_builtin_min(int n_args, const mp_obj_t *args) {
}
}
-static mp_obj_t mp_builtin_next(mp_obj_t o_in) {
- return mp_obj_gen_instance_next(o_in);
+static mp_obj_t mp_builtin_next(mp_obj_t o) {
+ mp_obj_t ret = rt_iternext(o);
+ if (ret == mp_const_stop_iteration) {
+ nlr_jump(mp_obj_new_exception(qstr_from_str_static("StopIteration")));
+ } else {
+ return ret;
+ }
}
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_next_obj, mp_builtin_next);
diff --git a/py/obj.h b/py/obj.h
index 7d58371dbb..bf598608e8 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -220,8 +220,6 @@ void mp_obj_fun_bc_get(mp_obj_t self_in, int *n_args, uint *n_state, const byte
// generator
extern const mp_obj_type_t gen_instance_type;
-mp_obj_t mp_obj_gen_instance_next(mp_obj_t self_in);
-MP_DECLARE_CONST_FUN_OBJ(mp_obj_gen_instance_next_obj);
// class
extern const mp_obj_type_t class_type;
diff --git a/py/objgenerator.c b/py/objgenerator.c
index fdb642c1c4..2a43b95348 100644
--- a/py/objgenerator.c
+++ b/py/objgenerator.c
@@ -117,14 +117,3 @@ mp_obj_t mp_obj_new_gen_instance(mp_obj_t state, const byte *ip, mp_obj_t *sp) {
o->sp = sp;
return o;
}
-
-mp_obj_t mp_obj_gen_instance_next(mp_obj_t self_in) {
- mp_obj_t ret = rt_iternext(self_in);
- if (ret == mp_const_stop_iteration) {
- nlr_jump(mp_obj_new_exception(qstr_from_str_static("StopIteration")));
- } else {
- return ret;
- }
-}
-
-MP_DEFINE_CONST_FUN_OBJ_1(mp_obj_gen_instance_next_obj, mp_obj_gen_instance_next);
diff --git a/py/runtime.c b/py/runtime.c
index a3d11f3c6c..7d1357a3fc 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -772,7 +772,7 @@ mp_obj_t rt_load_attr(mp_obj_t base, qstr attr) {
void rt_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest) {
DEBUG_OP_printf("load method %s\n", qstr_str(attr));
if (MP_OBJ_IS_TYPE(base, &gen_instance_type) && attr == rt_q___next__) {
- dest[1] = (mp_obj_t)&mp_obj_gen_instance_next_obj;
+ dest[1] = (mp_obj_t)&mp_builtin_next_obj;
dest[0] = base;
return;
} else if (MP_OBJ_IS_TYPE(base, &instance_type)) {