astropy/astropy — pull request #1533 by astrofrog (2013-10-05 21:21:06+00:00)
Title: Make sure the list of modules being iterated over cannot change during iteration

@mdboom - I'm not sure why, but under certain circumstances, I see the following error when testing:

```

self = , table_types =

def test_deprecated_attributes(self, table_types):
self._setup(table_types)
r = Row(self.t, 2)

> with catch_warnings(AstropyDeprecationWarning) as warning_lines:
r.dtypes

astropy/table/tests/test_row.py:168:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <[AttributeError("'catch_warnings' object has no attribute '_record'") raised in repr()] SafeRepr object at 0x1082a8cb0>
classes = (,), module =

def __init__(self, *classes):
> for module in six.itervalues(sys.modules):
if hasattr(module, '__warningregistry__'):
E RuntimeError: dictionary changed size during iteration

astropy/tests/helper.py:412: RuntimeError
```

By ensuring that the items being iterated over can't change during the iteration, the problem goes away. Is this pull request sensible, or do you think it's an issue I need to fix on my end?