|
7 | 7 | from __future__ import (absolute_import, division,
|
8 | 8 | print_function, unicode_literals)
|
9 | 9 | from future import utils
|
10 |
| -from future.builtins import * |
| 10 | +from future.builtins import str, range, open, int, map, list |
11 | 11 |
|
12 | 12 |
|
13 | 13 | # if __name__ != 'test.support':
|
@@ -955,7 +955,10 @@ def _filterwarnings(filters, quiet=False):
|
955 | 955 | frame = sys._getframe(2)
|
956 | 956 | registry = frame.f_globals.get('__warningregistry__')
|
957 | 957 | if registry:
|
958 |
| - registry.clear() |
| 958 | + # Was: registry.clear() |
| 959 | + # Py2-compatible: |
| 960 | + for i in range(len(registry)): |
| 961 | + registry.pop() |
959 | 962 | with warnings.catch_warnings(record=True) as w:
|
960 | 963 | # Set filter "always" to record all warnings. Because
|
961 | 964 | # test_warnings swap the module, we need to look up in
|
@@ -1709,7 +1712,12 @@ def modules_cleanup(oldmodules):
|
1709 | 1712 | # globals will be set to None which will trip up the cached functions.
|
1710 | 1713 | encodings = [(k, v) for k, v in sys.modules.items()
|
1711 | 1714 | if k.startswith('encodings.')]
|
1712 |
| - sys.modules.clear() |
| 1715 | + # Was: |
| 1716 | + # sys.modules.clear() |
| 1717 | + # Py2-compatible: |
| 1718 | + for i in range(len(sys.modules)): |
| 1719 | + sys.modules.pop() |
| 1720 | + |
1713 | 1721 | sys.modules.update(encodings)
|
1714 | 1722 | # XXX: This kind of problem can affect more than just encodings. In particular
|
1715 | 1723 | # extension modules (such as _ssl) don't cope with reloading properly.
|
|
0 commit comments