TypeError: 'NoneType' object is not iterable when applying decorator to generator
问题 I have a decorator function which I want to apply to both normal function and a generator. When applied to the normal function, it works properly. However, when applied to the generator, the iteration loop inside the decorator is executed till the end, but after that the script throws an error: TypeError: 'NoneType' object is not iterable and exits the script. def decor(func): def wrapper(*args, **kwargs): func_name = func.__name__ is_generator = "_generator" in func_name if is_generator: for