Skip to content
Snippets Groups Projects
Commit f69ab79e authored by Damien George's avatar Damien George
Browse files

py/objgenerator: Allow to hash generators and generator instances.

Adds nothing to the code size, since it uses existing empty slots in the
type structures.
parent 145796f0
No related branches found
No related tags found
No related merge requests found
......@@ -74,6 +74,7 @@ const mp_obj_type_t mp_type_gen_wrap = {
{ &mp_type_type },
.name = MP_QSTR_generator,
.call = gen_wrap_call,
.unary_op = mp_generic_unary_op,
};
mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun) {
......@@ -235,6 +236,7 @@ const mp_obj_type_t mp_type_gen_instance = {
{ &mp_type_type },
.name = MP_QSTR_generator,
.print = gen_instance_print,
.unary_op = mp_generic_unary_op,
.getiter = mp_identity_getiter,
.iternext = gen_instance_iternext,
.locals_dict = (mp_obj_dict_t*)&gen_instance_locals_dict,
......
# test builtin hash function, on generators
def gen():
yield
print(type(hash(gen)))
print(type(hash(gen())))
......@@ -323,6 +323,7 @@ def run_tests(pyb, tests, args, base_path="."):
skip_tests.update({'basics/%s.py' % t for t in 'with_break with_continue with_return'.split()}) # require complete with support
skip_tests.add('basics/array_construct2.py') # requires generators
skip_tests.add('basics/bool1.py') # seems to randomly fail
skip_tests.add('basics/builtin_hash_gen.py') # requires yield
skip_tests.add('basics/class_bind_self.py') # requires yield
skip_tests.add('basics/del_deref.py') # requires checking for unbound local
skip_tests.add('basics/del_local.py') # requires checking for unbound local
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment