Fix _execute_for_all_tables() in Python 3