diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-05-05 00:55:24 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-05-05 00:55:24 (GMT) |
commit | 7c67b03051e0c6db5057248623256f2b21e25a96 (patch) | |
tree | a159293d3bdbf787129cffba97cf813d0a83577a /Lib/collections.py | |
parent | 7ba8e1cbfdd262f809038fa590c6004ac71b3ce8 (diff) | |
download | cpython-7c67b03051e0c6db5057248623256f2b21e25a96.zip cpython-7c67b03051e0c6db5057248623256f2b21e25a96.tar.gz cpython-7c67b03051e0c6db5057248623256f2b21e25a96.tar.bz2 |
using sys._getframe(x), where x > 0 doesnt' work on IronPython
Diffstat (limited to 'Lib/collections.py')
-rw-r--r-- | Lib/collections.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/collections.py b/Lib/collections.py index 4cffca0..cac1777 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -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 |