diff options
| author | Michele Simionato <michele.simionato@gmail.com> | 2015-03-16 13:25:51 +0100 |
|---|---|---|
| committer | Michele Simionato <michele.simionato@gmail.com> | 2015-03-16 13:25:51 +0100 |
| commit | b68244d7e84dbc9c4d805c79d9a644e3526146ce (patch) | |
| tree | a4a2351d7dd7274058c98045be10ad627bc4db2e | |
| parent | d7d4bac90419a049165da9f29e2b8fef18fa7f33 (diff) | |
| download | python-decorator-git-b68244d7e84dbc9c4d805c79d9a644e3526146ce.tar.gz | |
Supported implementations without sys._getframe
| -rw-r--r-- | .travis.yml | 10 | ||||
| -rw-r--r-- | CHANGES.txt | 5 | ||||
| -rw-r--r-- | src/decorator.py | 7 |
3 files changed, 20 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..cf1dac1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +anguage: python + +python: + - "2.7" + +install: + - python setup.py install + +script: + python documentation.py diff --git a/CHANGES.txt b/CHANGES.txt index 41a2610..e4d9010 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,7 +2,10 @@ HISTORY ---------- 3.4.1 Ported the repository from GoogleCode to GitHub. - setuptools is made mandatory in Python 3. + setuptools is made mandatory in Python 3, and now the suggested + installation tool is pip, not easy_install. Supported IronPython + and other Python implementations without sys._getframe, as requested by + Doug Blank (2015/03/16) 3.4.0 Added the ability to use classes and generic callables as callers and implemented a signature-preserving contexmanager decorator. Fixed a bug with the signature f(**kw) in Python 3 and fixed a couple of doctests diff --git a/src/decorator.py b/src/decorator.py index f180823..4ed7247 100644 --- a/src/decorator.py +++ b/src/decorator.py @@ -138,7 +138,12 @@ class FunctionMaker(object): func.func_defaults = getattr(self, 'defaults', ()) func.__kwdefaults__ = getattr(self, 'kwonlydefaults', None) func.__annotations__ = getattr(self, 'annotations', None) - callermodule = sys._getframe(3).f_globals.get('__name__', '?') + try: + frame = sys._getframe(3) + except AttributeError: # for IronPython and similar implementations + callermodule = '?' + else: + callermodule = frame.f_globals.get('__name__', '?') func.__module__ = getattr(self, 'module', callermodule) func.__dict__.update(kw) |
