Eric Snow added the comment: I haven't looked to closely but I'm guessing that pdb.set_trace() causes something to get imported (i.e. there's an import statement in a function body somewhere). Consequently sys.modules is updated (by that "distant" import statement) while you are iterating over it here.
In that case the behavior you are seeing is correct, even if not obvious or even desirable. It will happen any time you are looping over sys.modules and call a function/method which has a function-scoped import statement for a module that hasn't been imported yet (or calls another function that does so, etc.). ---------- nosy: +eric.snow _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20703> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com