Bug #742342: make Python stop segfaulting on infinitely-recursive reload()s. Fixed by patch #922167.
Will backport.
diff --git a/Lib/test/infinite_reload.py b/Lib/test/infinite_reload.py
new file mode 100644
index 0000000..bfbec91
--- /dev/null
+++ b/Lib/test/infinite_reload.py
@@ -0,0 +1,7 @@
+# For testing http://python.org/sf/742342, which reports that Python
+# segfaults (infinite recursion in C) in the presence of infinite
+# reload()ing. This module is imported by test_import.py:test_infinite_reload
+# to make sure this doesn't happen any more.
+
+import infinite_reload
+reload(infinite_reload)
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index a6db281..cc932a2 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -192,6 +192,16 @@
remove_files(TESTFN)
if TESTFN in sys.modules:
del sys.modules[TESTFN]
+
+ def test_infinite_reload(self):
+ # Bug #742342 reports that Python segfaults (infinite recursion in C)
+ # when faced with self-recursive reload()ing.
+
+ sys.path.insert(0, os.path.dirname(__file__))
+ try:
+ import infinite_reload
+ finally:
+ sys.path.pop(0)
def test_import_name_binding(self):
# import x.y.z binds x in the current namespace