Issue 5021: doctest.testfile should set __name__
diff --git a/Lib/collections.py b/Lib/collections.py
index 6831cf1..4bde5b3 100644
--- a/Lib/collections.py
+++ b/Lib/collections.py
@@ -111,7 +111,7 @@
# where the named tuple is created. Bypass this step in enviroments where
# sys._getframe is not defined (Jython for example).
if hasattr(_sys, '_getframe'):
- result.__module__ = _sys._getframe(1).f_globals['__name__']
+ result.__module__ = _sys._getframe(1).f_globals.get('__name__', '__main__')
return result