]> granicus.if.org Git - python/commitdiff
using sys._getframe(x), where x > 0 doesnt' work on IronPython
authorBenjamin Peterson <benjamin@python.org>
Tue, 5 May 2009 00:55:24 +0000 (00:55 +0000)
committerBenjamin Peterson <benjamin@python.org>
Tue, 5 May 2009 00:55:24 +0000 (00:55 +0000)
Lib/collections.py

index 4cffca00f5c43ddb23e1df278e2e22008945a0c1..cac1777ecb71016c74b655512668df0260cac11a 100644 (file)
@@ -268,9 +268,12 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
 
     # For pickling to work, the __module__ variable needs to be set to the frame
     # where the named tuple is created.  Bypass this step in enviroments where
-    # sys._getframe is not defined (Jython for example).
-    if hasattr(_sys, '_getframe'):
+    # sys._getframe is not defined (Jython for example) or sys._getframe is not
+    # defined for arguments greater than 0 (IronPython).
+    try:
         result.__module__ = _sys._getframe(1).f_globals.get('__name__', '__main__')
+    except (AttributeError, ValueError):
+        pass
 
     return result