As mentioned on python-dev, reverting patch #1504333 because it introduced
an infinite loop in rev 47154.

This patch also adds a test to prevent the regression.

Will backport to 2.4 and head later.
diff --git a/Misc/NEWS b/Misc/NEWS
index b2f48f8..1feda61 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -49,6 +49,8 @@
 Library
 -------
 
+- Reverted patch #1504333 because it introduced an infinite loop.
+
 - Patch #1553314: Fix the inspect.py slowdown that was hurting IPython & SAGE
   by adding smarter caching in inspect.getmodule().