Hello community,
here is the log from the commit of package python-decorator for
openSUSE:Factory checked in at 2019-02-25 17:44:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-decorator (Old)
and /work/SRC/openSUSE:Factory/.python-decorator.new.28833 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-decorator"
Mon Feb 25 17:44:33 2019 rev:19 rq:674687 version:4.3.2
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-decorator/python-decorator.changes
2018-12-06 12:14:40.733689866 +0100
+++
/work/SRC/openSUSE:Factory/.python-decorator.new.28833/python-decorator.changes
2019-02-25 17:44:36.298926051 +0100
@@ -1,0 +2,14 @@
+Wed Feb 13 17:32:05 UTC 2019 - Todd R <[email protected]>
+
+- update to version 4.3.2
+ * now the decorator module can decorate generator functions by
+ preserving their being generator functions
+ * Set `python_requires='>=2.6, !=3.0.*, !=3.1.*'` in setup.py
+- update to version 4.3.1
+ * Added a section "For the impatient" to the README, addressing
+ an issue raised by Amir Malekpour.
+ * Added support for Python 3.7.
+ * Now the path to the decorator module appears in the
+ tracebacks, as suggested by a user at EuroPython 2018.
+
+-------------------------------------------------------------------
Old:
----
decorator-4.3.0.tar.gz
New:
----
decorator-4.3.2.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-decorator.spec ++++++
--- /var/tmp/diff_new_pack.V5S1IQ/_old 2019-02-25 17:44:37.882925400 +0100
+++ /var/tmp/diff_new_pack.V5S1IQ/_new 2019-02-25 17:44:37.886925399 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-decorator
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -20,7 +20,7 @@
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-decorator
-Version: 4.3.0
+Version: 4.3.2
Release: 0
Summary: Non-nested signature-retaining Python decorators
License: BSD-2-Clause
@@ -28,6 +28,7 @@
URL: http://pypi.python.org/pypi/decorator
Source:
https://files.pythonhosted.org/packages/source/d/decorator/decorator-%{version}.tar.gz
BuildRequires: %{python_module setuptools}
+BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildArch: noarch
%python_subpackages
@@ -43,17 +44,18 @@
%prep
%setup -q -n decorator-%{version}
-sed -i 's/\r//' docs/README.rst # Fix EOL encoding
+sed -i 's/\r//' README.rst # Fix EOL encoding
%build
%python_build
%install
%python_install
+%python_expand %fdupes %{buildroot}%{$python_sitelib}
%files %{python_files}
%license LICENSE.txt
-%doc CHANGES.md docs/README.rst
+%doc CHANGES.md README.rst
%{python_sitelib}/decorator.py*
%pycache_only %{python_sitelib}/__pycache__/decorator.*.py*
%{python_sitelib}/decorator-%{version}-py*.egg-info
++++++ decorator-4.3.0.tar.gz -> decorator-4.3.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/decorator-4.3.0/CHANGES.md
new/decorator-4.3.2/CHANGES.md
--- old/decorator-4.3.0/CHANGES.md 2018-04-15 14:45:04.000000000 +0200
+++ new/decorator-4.3.2/CHANGES.md 2019-01-24 15:02:13.000000000 +0100
@@ -1,7 +1,21 @@
HISTORY
--------
-## Unreleased
+## unreleased
+
+## 4.3.2 (2019-01-24)
+
+Accepted a patch from Sylvain Marie (https://github.com/smarie): now the
+decorator module can decorate generator functions by preserving their
+being generator functions. Set `python_requires='>=2.6, !=3.0.*, !=3.1.*'`
+in setup.py, as suggested by https://github.com/hugovk.
+
+## 4.3.1 (2018-08-04)
+
+Added a section "For the impatient" to the README, addressing an issue
+raised by Amir Malekpour. Added support for Python 3.7. Now
+the path to the decorator module appears in the tracebacks, as suggested
+by an user at EuroPython 2018.
## 4.3.0 (2018-04-15)
@@ -205,7 +219,7 @@
functions; referenced PEP 326; highlighted the snippets in the
documentation with pygments; slightly simplified the code.
-## 2.1.0. (3/07/2007)
+## 2.1.0. (2007-07-03)
Replaced the utility 'update_wrapper' with 'new_wrapper' and
updated the documentation accordingly; fixed and improved the
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/decorator-4.3.0/LICENSE.txt
new/decorator-4.3.2/LICENSE.txt
--- old/decorator-4.3.0/LICENSE.txt 2017-01-15 10:59:31.000000000 +0100
+++ new/decorator-4.3.2/LICENSE.txt 2018-04-15 15:31:05.000000000 +0200
@@ -1,4 +1,4 @@
-Copyright (c) 2005-2017, Michele Simionato
+Copyright (c) 2005-2018, Michele Simionato
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/decorator-4.3.0/MANIFEST.in
new/decorator-4.3.2/MANIFEST.in
--- old/decorator-4.3.0/MANIFEST.in 2016-06-02 08:41:09.000000000 +0200
+++ new/decorator-4.3.2/MANIFEST.in 2018-05-12 05:32:21.000000000 +0200
@@ -1,2 +1,2 @@
-include docs/README.rst LICENSE.txt CHANGES.md performance.sh documentation.pdf
+include README.rst LICENSE.txt CHANGES.md performance.sh documentation.pdf
recursive-include src/tests *.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/decorator-4.3.0/PKG-INFO new/decorator-4.3.2/PKG-INFO
--- old/decorator-4.3.0/PKG-INFO 2018-04-15 14:50:29.000000000 +0200
+++ new/decorator-4.3.2/PKG-INFO 2019-01-24 15:02:47.000000000 +0100
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
Name: decorator
-Version: 4.3.0
+Version: 4.3.2
Summary: Better living through Python with decorators
Home-page: https://github.com/micheles/decorator
Author: Michele Simionato
@@ -11,11 +11,14 @@
:Author: Michele Simionato
:E-mail: [email protected]
- :Requires: Python from 2.6 to 3.6
+ :Requires: Python from 2.6 to 3.7
:Download page: http://pypi.python.org/pypi/decorator
:Installation: ``pip install decorator``
:License: BSD license
+ The goal of the decorator module is to make it easy to define
+ signature-preserving function decorators.
+
Installation
-------------
@@ -64,6 +67,38 @@
The documentation has been moved to
http://decorator.readthedocs.io/en/latest/
You can download a PDF version of it from
http://media.readthedocs.org/pdf/decorator/latest/decorator.pdf
+ For the impatient
+ -----------------
+
+ Here is an example of how to define a family of decorators tracing slow
+ operations:
+
+ .. code-block:: python
+
+ from decorator import decorator
+
+ @decorator
+ def warn_slow(func, timelimit=60, *args, **kw):
+ t0 = time.time()
+ result = func(*args, **kw)
+ dt = time.time() - t0
+ if dt > timelimit:
+ logging.warn('%s took %d seconds', func.__name__, dt)
+ else:
+ logging.info('%s took %d seconds', func.__name__, dt)
+ return result
+
+ @warn_slow # warn if it takes more than 1 minute
+ def preprocess_input_files(inputdir, tempdir):
+ ...
+
+ @warn_slow(timelimit=600) # warn if it takes more than 10 minutes
+ def run_calculation(tempdir, outdir):
+ ...
+
+ Enjoy!
+
+
Keywords: decorators generic utility
Platform: All
Classifier: Development Status :: 5 - Production/Stable
@@ -81,6 +116,8 @@
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
+Requires-Python: >=2.6, !=3.0.*, !=3.1.*
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/decorator-4.3.0/README.md
new/decorator-4.3.2/README.md
--- old/decorator-4.3.0/README.md 2015-07-28 05:49:22.000000000 +0200
+++ new/decorator-4.3.2/README.md 1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +0,0 @@
-[See the real README](docs/README.rst)
-
-[](https://travis-ci.org/micheles/decorator)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/decorator-4.3.0/README.rst
new/decorator-4.3.2/README.rst
--- old/decorator-4.3.0/README.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/decorator-4.3.2/README.rst 2019-01-24 14:49:32.000000000 +0100
@@ -0,0 +1,92 @@
+Decorator module
+=================
+
+:Author: Michele Simionato
+:E-mail: [email protected]
+:Requires: Python from 2.6 to 3.7
+:Download page: http://pypi.python.org/pypi/decorator
+:Installation: ``pip install decorator``
+:License: BSD license
+
+The goal of the decorator module is to make it easy to define
+signature-preserving function decorators.
+
+Installation
+-------------
+
+If you are lazy, just perform
+
+ `$ pip install decorator`
+
+which will install just the module on your system.
+
+If you prefer to install the full distribution from source, including
+the documentation, clone the `GitHub repo`_ or download the tarball_, unpack
it and run
+
+ `$ pip install .`
+
+in the main directory, possibly as superuser.
+
+.. _tarball: http://pypi.python.org/pypi/decorator
+.. _GitHub repo: https://github.com/micheles/decorator
+
+Testing
+--------
+
+If you have the source code installation you can run the tests with
+
+ `$ python src/tests/test.py -v`
+
+or (if you have setuptools installed)
+
+ `$ python setup.py test`
+
+Notice that you may run into trouble if in your system there
+is an older version of the decorator module; in such a case remove the
+old version. It is safe even to copy the module `decorator.py` over
+an existing one, since we kept backward-compatibility for a long time.
+
+Repository
+---------------
+
+The project is hosted on GitHub. You can look at the source here:
+
+ https://github.com/micheles/decorator
+
+Documentation
+---------------
+
+The documentation has been moved to http://decorator.readthedocs.io/en/latest/
+You can download a PDF version of it from
http://media.readthedocs.org/pdf/decorator/latest/decorator.pdf
+
+For the impatient
+-----------------
+
+Here is an example of how to define a family of decorators tracing slow
+operations:
+
+.. code-block:: python
+
+ from decorator import decorator
+
+ @decorator
+ def warn_slow(func, timelimit=60, *args, **kw):
+ t0 = time.time()
+ result = func(*args, **kw)
+ dt = time.time() - t0
+ if dt > timelimit:
+ logging.warn('%s took %d seconds', func.__name__, dt)
+ else:
+ logging.info('%s took %d seconds', func.__name__, dt)
+ return result
+
+ @warn_slow # warn if it takes more than 1 minute
+ def preprocess_input_files(inputdir, tempdir):
+ ...
+
+ @warn_slow(timelimit=600) # warn if it takes more than 10 minutes
+ def run_calculation(tempdir, outdir):
+ ...
+
+Enjoy!
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/decorator-4.3.0/docs/README.rst
new/decorator-4.3.2/docs/README.rst
--- old/decorator-4.3.0/docs/README.rst 2018-01-14 10:40:35.000000000 +0100
+++ new/decorator-4.3.2/docs/README.rst 1970-01-01 01:00:00.000000000 +0100
@@ -1,57 +0,0 @@
-Decorator module
-=================
-
-:Author: Michele Simionato
-:E-mail: [email protected]
-:Requires: Python from 2.6 to 3.6
-:Download page: http://pypi.python.org/pypi/decorator
-:Installation: ``pip install decorator``
-:License: BSD license
-
-Installation
--------------
-
-If you are lazy, just perform
-
- `$ pip install decorator`
-
-which will install just the module on your system.
-
-If you prefer to install the full distribution from source, including
-the documentation, clone the `GitHub repo`_ or download the tarball_, unpack
it and run
-
- `$ pip install .`
-
-in the main directory, possibly as superuser.
-
-.. _tarball: http://pypi.python.org/pypi/decorator
-.. _GitHub repo: https://github.com/micheles/decorator
-
-Testing
---------
-
-If you have the source code installation you can run the tests with
-
- `$ python src/tests/test.py -v`
-
-or (if you have setuptools installed)
-
- `$ python setup.py test`
-
-Notice that you may run into trouble if in your system there
-is an older version of the decorator module; in such a case remove the
-old version. It is safe even to copy the module `decorator.py` over
-an existing one, since we kept backward-compatibility for a long time.
-
-Repository
----------------
-
-The project is hosted on GitHub. You can look at the source here:
-
- https://github.com/micheles/decorator
-
-Documentation
----------------
-
-The documentation has been moved to http://decorator.readthedocs.io/en/latest/
-You can download a PDF version of it from
http://media.readthedocs.org/pdf/decorator/latest/decorator.pdf
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/decorator-4.3.0/setup.py new/decorator-4.3.2/setup.py
--- old/decorator-4.3.0/setup.py 2018-01-14 10:38:21.000000000 +0100
+++ new/decorator-4.3.2/setup.py 2019-01-24 14:49:32.000000000 +0100
@@ -1,7 +1,7 @@
from setuptools import setup
-dic = {}
-exec(open('src/decorator.py').read(), dic)
+dic = dict(__file__=None)
+exec(open('src/decorator.py').read(), dic) # extract the __version__
VERSION = dic['__version__']
@@ -9,7 +9,7 @@
setup(name='decorator',
version=VERSION,
description='Better living through Python with decorators',
- long_description=open('docs/README.rst').read(),
+ long_description=open('README.rst').read(),
author='Michele Simionato',
author_email='[email protected]',
url='https://github.com/micheles/decorator',
@@ -18,6 +18,7 @@
py_modules=['decorator'],
keywords="decorators generic utility",
platforms=["All"],
+ python_requires='>=2.6, !=3.0.*, !=3.1.*',
classifiers=['Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
@@ -33,6 +34,7 @@
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation ::
CPython',
'Topic :: Software Development :: Libraries',
'Topic :: Utilities'],
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/decorator-4.3.0/src/decorator.egg-info/PKG-INFO
new/decorator-4.3.2/src/decorator.egg-info/PKG-INFO
--- old/decorator-4.3.0/src/decorator.egg-info/PKG-INFO 2018-04-15
14:50:28.000000000 +0200
+++ new/decorator-4.3.2/src/decorator.egg-info/PKG-INFO 2019-01-24
15:02:46.000000000 +0100
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
Name: decorator
-Version: 4.3.0
+Version: 4.3.2
Summary: Better living through Python with decorators
Home-page: https://github.com/micheles/decorator
Author: Michele Simionato
@@ -11,11 +11,14 @@
:Author: Michele Simionato
:E-mail: [email protected]
- :Requires: Python from 2.6 to 3.6
+ :Requires: Python from 2.6 to 3.7
:Download page: http://pypi.python.org/pypi/decorator
:Installation: ``pip install decorator``
:License: BSD license
+ The goal of the decorator module is to make it easy to define
+ signature-preserving function decorators.
+
Installation
-------------
@@ -64,6 +67,38 @@
The documentation has been moved to
http://decorator.readthedocs.io/en/latest/
You can download a PDF version of it from
http://media.readthedocs.org/pdf/decorator/latest/decorator.pdf
+ For the impatient
+ -----------------
+
+ Here is an example of how to define a family of decorators tracing slow
+ operations:
+
+ .. code-block:: python
+
+ from decorator import decorator
+
+ @decorator
+ def warn_slow(func, timelimit=60, *args, **kw):
+ t0 = time.time()
+ result = func(*args, **kw)
+ dt = time.time() - t0
+ if dt > timelimit:
+ logging.warn('%s took %d seconds', func.__name__, dt)
+ else:
+ logging.info('%s took %d seconds', func.__name__, dt)
+ return result
+
+ @warn_slow # warn if it takes more than 1 minute
+ def preprocess_input_files(inputdir, tempdir):
+ ...
+
+ @warn_slow(timelimit=600) # warn if it takes more than 10 minutes
+ def run_calculation(tempdir, outdir):
+ ...
+
+ Enjoy!
+
+
Keywords: decorators generic utility
Platform: All
Classifier: Development Status :: 5 - Production/Stable
@@ -81,6 +116,8 @@
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
+Requires-Python: >=2.6, !=3.0.*, !=3.1.*
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/decorator-4.3.0/src/decorator.egg-info/SOURCES.txt
new/decorator-4.3.2/src/decorator.egg-info/SOURCES.txt
--- old/decorator-4.3.0/src/decorator.egg-info/SOURCES.txt 2018-04-15
14:50:29.000000000 +0200
+++ new/decorator-4.3.2/src/decorator.egg-info/SOURCES.txt 2019-01-24
15:02:47.000000000 +0100
@@ -1,11 +1,10 @@
CHANGES.md
LICENSE.txt
MANIFEST.in
-README.md
+README.rst
performance.sh
setup.cfg
setup.py
-docs/README.rst
src/decorator.py
src/decorator.egg-info/PKG-INFO
src/decorator.egg-info/SOURCES.txt
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/decorator-4.3.0/src/decorator.py
new/decorator-4.3.2/src/decorator.py
--- old/decorator-4.3.0/src/decorator.py 2018-04-15 14:45:04.000000000
+0200
+++ new/decorator-4.3.2/src/decorator.py 2019-01-24 15:02:13.000000000
+0100
@@ -40,7 +40,7 @@
import itertools
import collections
-__version__ = '4.3.0'
+__version__ = '4.3.2'
if sys.version >= '3':
from inspect import getfullargspec
@@ -65,6 +65,12 @@
# let's assume there are no coroutine functions in old Python
def iscoroutinefunction(f):
return False
+try:
+ from inspect import isgeneratorfunction
+except ImportError:
+ # assume no generator function in old Python versions
+ def isgeneratorfunction():
+ return False
DEF = re.compile(r'\s*def\s*([_\w][_\w\d]*)\s*\(')
@@ -173,7 +179,8 @@
# Ensure each generated function has a unique filename for profilers
# (such as cProfile) that depend on the tuple of (<filename>,
# <definition line>, <function name>) being unique.
- filename = '<decorator-gen-%d>' % (next(self._compile_count),)
+ filename = '<%s:decorator-gen-%d>' % (
+ __file__, next(self._compile_count))
try:
code = compile(src, filename, 'single')
exec(code, evaldict)
@@ -218,6 +225,8 @@
def decorate(func, caller, extras=()):
"""
decorate(func, caller) decorates a function using a caller.
+ If the caller is a generator function, the resulting function
+ will be a generator function.
"""
evaldict = dict(_call_=caller, _func_=func)
es = ''
@@ -225,9 +234,23 @@
ex = '_e%d_' % i
evaldict[ex] = extra
es += ex + ', '
- fun = FunctionMaker.create(
- func, "return _call_(_func_, %s%%(shortsignature)s)" % es,
- evaldict, __wrapped__=func)
+
+ if '3.5' <= sys.version < '3.6':
+ # with Python 3.5 isgeneratorfunction returns True for all coroutines
+ # however we know that it is NOT possible to have a generator
+ # coroutine in python 3.5: PEP525 was not there yet
+ generatorcaller = isgeneratorfunction(
+ caller) and not iscoroutinefunction(caller)
+ else:
+ generatorcaller = isgeneratorfunction(caller)
+ if generatorcaller:
+ fun = FunctionMaker.create(
+ func, "for res in _call_(_func_, %s%%(shortsignature)s):\n"
+ " yield res" % es, evaldict, __wrapped__=func)
+ else:
+ fun = FunctionMaker.create(
+ func, "return _call_(_func_, %s%%(shortsignature)s)" % es,
+ evaldict, __wrapped__=func)
if hasattr(func, '__qualname__'):
fun.__qualname__ = func.__qualname__
return fun
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/decorator-4.3.0/src/tests/documentation.py
new/decorator-4.3.2/src/tests/documentation.py
--- old/decorator-4.3.0/src/tests/documentation.py 2018-04-15
14:48:08.000000000 +0200
+++ new/decorator-4.3.2/src/tests/documentation.py 2018-08-04
07:10:23.000000000 +0200
@@ -1,4 +1,16 @@
from __future__ import print_function
+import sys
+import threading
+import time
+import functools
+import itertools
+import collections
+try:
+ import collections.abc as c
+except ImportError:
+ c = collections
+from decorator import (decorator, decorate, FunctionMaker, contextmanager,
+ dispatch_on, __version__)
doc = r"""\
The ``decorator`` module
@@ -6,7 +18,7 @@
:Author: Michele Simionato
:E-mail: [email protected]
:Version: $VERSION ($DATE)
-:Supports: Python 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6
+:Supports: Python 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7
:Download page: http://pypi.python.org/pypi/decorator/$VERSION
:Installation: ``pip install decorator``
:License: BSD license
@@ -371,7 +383,7 @@
return decorator(caller)
This is fully general but requires an additional level of nesting. For this
-reasone since version 4.2 there is a facility to build
+reason since version 4.2 there is a facility to build
decorator factories by using a single caller with default arguments i.e.
writing something like this:
@@ -385,7 +397,7 @@
i.e. `param1`, `param2` etc must have known defaults. Thanks to this
restriction, there exists an unique default decorator, i.e. the member
of the family which uses the default values for all parameters. Such
-decorator can be written as `decfactory()` with no parameters specified;
+decorator can be written as ``decfactory()`` with no parameters specified;
moreover, as a shortcut, it is also possible to elide the parenthesis,
a feature much requested by the users. For years I have been opposite
to this feature request, since having expliciti parenthesis to me is more clear
@@ -441,17 +453,6 @@
$$restricted
-In general a decorator factory has a signature
-
-.. code-block:: python
-
- def decfactory(func, par1=default1, .., parN=defaultN, *a, **k):
- ...
-
-Each parameter must have a default, so that ``decfactory`` can work
-as an alias for ``decfactory()``, i.e. the decorator in which all parameters
-have the default value.
-
``decorator(cls)``
--------------------------------------------
@@ -1374,16 +1375,6 @@
the qualified name. This attribute was introduced in Python 3.3.
"""
-import sys
-import threading
-import time
-import functools
-import itertools
-import collections
-import collections as c
-from decorator import (decorator, decorate, FunctionMaker, contextmanager,
- dispatch_on, __version__)
-
if sys.version < '3':
function_annotations = ''
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/decorator-4.3.0/src/tests/test.py
new/decorator-4.3.2/src/tests/test.py
--- old/decorator-4.3.0/src/tests/test.py 2018-04-15 14:45:04.000000000
+0200
+++ new/decorator-4.3.2/src/tests/test.py 2019-01-24 14:49:32.000000000
+0100
@@ -6,10 +6,15 @@
import inspect
import functools
import collections
+from collections import defaultdict
+try:
+ c = collections.abc
+except AttributeError:
+ c = collections
from decorator import dispatch_on, contextmanager, decorator
try:
from . import documentation as doc
-except:
+except (ImportError, ValueError, SystemError): # depending on the py-version
import documentation as doc
@@ -23,6 +28,7 @@
else:
raise Exception('Expected %s' % etype.__name__)
+
if sys.version >= '3.5':
exec('''from asyncio import get_event_loop
@@ -52,6 +58,23 @@
''')
+def gen123():
+ yield 1
+ yield 2
+ yield 3
+
+
+class GeneratorCallerTestCase(unittest.TestCase):
+ def test_gen123(self):
+ @decorator
+ def square(func, *args, **kw):
+ for x in gen123():
+ yield x * x
+ new = square(gen123)
+ self.assertTrue(inspect.isgeneratorfunction(new))
+ self.assertEqual(list(new()), [1, 4, 9])
+
+
class DocumentationTestCase(unittest.TestCase):
def test(self):
err = doctest.testmod(doc)[0]
@@ -237,7 +260,6 @@
self.assertEqual(g(rnd), ("Number got rounded",))
def test_register_abc(self):
- c = collections
d = {"a": "b"}
l = [1, 2, 3]
s = set([object(), None])
@@ -348,8 +370,6 @@
self.assertEqual(g(t), "tuple")
def test_mro_conflicts(self):
- c = collections
-
@singledispatch
def g(obj):
return "base"
@@ -410,9 +430,9 @@
# MutableMapping's bases implicit as well from defaultdict's
# perspective.
with assertRaises(RuntimeError):
- self.assertEqual(h(c.defaultdict(lambda: 0)), "sized")
+ self.assertEqual(h(defaultdict(lambda: 0)), "sized")
- class R(c.defaultdict):
+ class R(defaultdict):
pass
c.MutableSequence.register(R)