Make sure the list of modules being iterated over cannot change during the iteration.
Merge pull request #1533 from astrofrog/fix-catch-warning-issue

Make sure the list of modules being iterated over cannot change during iteration