Hello community, here is the log from the commit of package python-treq for openSUSE:Factory checked in at 2020-07-26 16:18:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-treq (Old) and /work/SRC/openSUSE:Factory/.python-treq.new.3592 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-treq" Sun Jul 26 16:18:47 2020 rev:6 rq:822412 version:20.4.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-treq/python-treq.changes 2020-03-25 23:50:05.564023801 +0100 +++ /work/SRC/openSUSE:Factory/.python-treq.new.3592/python-treq.changes 2020-07-26 16:19:43.220829405 +0200 @@ -1,0 +2,8 @@ +Thu Jul 23 13:10:39 UTC 2020 - Marketa Calabkova <mcalabk...@suse.com> + +- update to 20.4.1 + * Support for Python 3.8 and PyPy3: treq is now tested with these interpreters. + * `treq.client.HTTPClient.request()` and its aliases no longer raise `UnicodeEncodeError` when passed a Unicode *url* and non-empty *params*. + * In treq 20.3.0 the *params* argument didn't accept parameter names or values that contain the characters ``&`` or ``#``. + +------------------------------------------------------------------- Old: ---- treq-20.3.0.tar.gz New: ---- treq-20.4.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-treq.spec ++++++ --- /var/tmp/diff_new_pack.3HxFTS/_old 2020-07-26 16:19:44.764830849 +0200 +++ /var/tmp/diff_new_pack.3HxFTS/_new 2020-07-26 16:19:44.764830849 +0200 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-treq -Version: 20.3.0 +Version: 20.4.1 Release: 0 Summary: HTTP library inspired by python-requests License: MIT @@ -28,6 +28,7 @@ BuildRequires: %{python_module Twisted >= 16.4.0} BuildRequires: %{python_module attrs} BuildRequires: %{python_module httpbin} +BuildRequires: %{python_module hyperlink >= 19.0.0} BuildRequires: %{python_module incremental} BuildRequires: %{python_module mock} BuildRequires: %{python_module requests >= 2.1.0} @@ -38,6 +39,7 @@ BuildRequires: python-rpm-macros Requires: python-Twisted >= 18.7.0 Requires: python-attrs +Requires: python-hyperlink >= 19.0.0 Requires: python-incremental Requires: python-requests >= 2.1.0 Requires: python-six ++++++ treq-20.3.0.tar.gz -> treq-20.4.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/treq-20.3.0/CHANGELOG.rst new/treq-20.4.1/CHANGELOG.rst --- old/treq-20.3.0/CHANGELOG.rst 2020-03-16 04:39:03.000000000 +0100 +++ new/treq-20.4.1/CHANGELOG.rst 2020-04-17 07:00:02.000000000 +0200 @@ -8,6 +8,38 @@ .. towncrier release notes start +20.4.1 (2020-04-16) +=================== + +Bugfixes +-------- + +- Correct a typo in the treq 20.4.0 package metadata that prevented upload to PyPI (`pypa/twine#589 <https://github.com/pypa/twine/issues/589>`__) + +20.4.0 (2020-04-16) +=================== + +Features +-------- + +- Support for Python 3.8 and PyPy3: treq is now tested with these interpreters. (`#271 <https://github.com/twisted/treq/issues/271>`__) + + +Bugfixes +-------- + +- `treq.client.HTTPClient.request()` and its aliases no longer raise `UnicodeEncodeError` when passed a Unicode *url* and non-empty *params*. + Now the URL and query parameters are concatenated as documented. (`#264 <https://github.com/twisted/treq/issues/264>`__) +- In treq 20.3.0 the *params* argument didn't accept parameter names or values that contain the characters ``&`` or ``#``. + Now these characters are properly escaped. (`#282 <https://github.com/twisted/treq/issues/282>`__) + + +Improved Documentation +---------------------- + +- The treq documentation has been revised to emphasize use of `treq.client.HTTPClient` over the module-level convenience functions in the `treq` module. (`#276 <https://github.com/twisted/treq/issues/276>`__) + + 20.3.0 (2020-03-15) =================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/treq-20.3.0/PKG-INFO new/treq-20.4.1/PKG-INFO --- old/treq-20.3.0/PKG-INFO 2020-03-16 04:39:35.000000000 +0100 +++ new/treq-20.4.1/PKG-INFO 2020-04-17 07:01:10.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: treq -Version: 20.3.0 +Version: 20.4.1 Summary: High-level Twisted HTTP Client API Home-page: https://github.com/twisted/treq Author: David Reid @@ -79,6 +79,8 @@ Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy +Description-Content-Type: text/x-rst Provides-Extra: dev diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/treq-20.3.0/docs/api.rst new/treq-20.4.1/docs/api.rst --- old/treq-20.3.0/docs/api.rst 2020-03-14 20:33:17.000000000 +0100 +++ new/treq-20.4.1/docs/api.rst 2020-03-28 21:22:24.000000000 +0100 @@ -6,6 +6,9 @@ Making Requests --------------- +The :py:mod:`treq` module provides several convenience functions for making requests. +These functions all create a default :py:class:`treq.client.HTTPClient` instance and pass their arguments to the appropriate :py:class:`~treq.client.HTTPClient` method. + .. module:: treq .. autofunction:: request @@ -24,14 +27,14 @@ .. autofunction:: text_content .. autofunction:: json_content -HTTPClient Objects ------------------- +The HTTP Client +=============== .. module:: treq.client -The :class:`treq.client.HTTPClient` class provides the same interface as the :mod:`treq` module itself. +:class:`treq.client.HTTPClient` has methods that match the signatures of the convenience request functions in the :mod:`treq` module. -.. autoclass:: HTTPClient +.. autoclass:: HTTPClient(agent, cookiejar=None, data_to_body_producer=IBodyProducer) .. automethod:: request .. automethod:: get @@ -79,6 +82,8 @@ Test Helpers ------------ +.. module:: treq.testing + The :mod:`treq.testing` module contains tools for in-memory testing of HTTP clients and servers. StubTreq Objects diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/treq-20.3.0/docs/examples/custom_agent.py new/treq-20.4.1/docs/examples/custom_agent.py --- old/treq-20.3.0/docs/examples/custom_agent.py 1970-01-01 01:00:00.000000000 +0100 +++ new/treq-20.4.1/docs/examples/custom_agent.py 2020-03-28 21:22:24.000000000 +0100 @@ -0,0 +1,19 @@ +from treq.client import HTTPClient +from _utils import print_response +from twisted.internet.task import react +from twisted.web.client import Agent + +def make_custom_agent(reactor): + return Agent(reactor, connectTimeout=42) + +def main(reactor, *args): + agent = make_custom_agent(reactor) + http_client = HTTPClient(agent) + d = http_client.get( + 'https://secure.example.net/area51', + auth=('admin', "you'll never guess!")) + d.addCallback(print_response) + return d + +react(main, []) + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/treq-20.3.0/docs/howto.rst new/treq-20.4.1/docs/howto.rst --- old/treq-20.3.0/docs/howto.rst 2020-03-15 22:23:23.000000000 +0100 +++ new/treq-20.4.1/docs/howto.rst 2020-04-06 08:32:51.000000000 +0200 @@ -24,7 +24,7 @@ Query Parameters ---------------- -:py:func:`treq.request` supports a ``params`` keyword argument which will +:py:func:`treq.HTTPClient.request` supports a ``params`` keyword argument which will be URL-encoded and added to the ``url`` argument in addition to any query parameters that may already exist. @@ -91,7 +91,7 @@ Cookies can be set by passing a ``dict`` or ``cookielib.CookieJar`` instance via the ``cookies`` keyword argument. Later cookies set by the server can be -retrieved using the :py:meth:`~treq.response._Response.cookies()` method. +retrieved using the :py:meth:`~treq.response._Response.cookies()` method of the response. The object returned by :py:meth:`~treq.response._Response.cookies()` supports the same key/value access as `requests cookies <https://requests.readthedocs.io/en/latest/user/quickstart/#cookies>`_. @@ -102,25 +102,21 @@ Full example: :download:`using_cookies.py <examples/using_cookies.py>` -Agent Customization -------------------- +Customizing the Twisted Agent +----------------------------- -treq creates its own `twisted.web.client.Agent -<https://twistedmatrix.com/documents/current/api/twisted.web.client.Agent.html>`_ -with reasonable defaults, but you may want to provide your own custom agent. -A custom agent can be passed to the various treq request methods using the -``agent`` keyword argument. +The main :py:mod:`treq` module has helper functions that automatically instantiate +an instance of :py:class:`treq.client.HTTPClient`. You can create an instance +of :py:class:`~treq.client.HTTPClient` directly in order to customize the +paramaters used to initialize it. +Internally, the :py:class:`~treq.client.HTTPClient` wraps an instance of +:py:class:`twisted.web.client.Agent`. When you create an instance of +:py:class:`~treq.client.HTTPClient`, you must initialize it with an instance of +:py:class:`~twisted.web.client.Agent`. This allows you to customize its +behavior. -.. code-block:: python - - custom_agent = Agent(reactor, connectTimeout=42) - treq.get(url, agent=custom_agent) - -Additionally a custom client can be instantiated to use a custom agent -using the ``agent`` keyword argument: - -.. code-block:: python +.. literalinclude:: examples/custom_agent.py + :linenos: + :lines: 6-19 - custom_agent = Agent(reactor, connectTimeout=42) - client = treq.client.HTTPClient(agent=custom_agent) - client.get(url) +Full example: :download:`custom_agent.py <examples/custom_agent.py>` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/treq-20.3.0/setup.py new/treq-20.4.1/setup.py --- old/treq-20.3.0/setup.py 2020-03-16 04:02:45.000000000 +0100 +++ new/treq-20.4.1/setup.py 2020-04-17 06:53:34.000000000 +0200 @@ -11,6 +11,7 @@ "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", ] @@ -29,6 +30,7 @@ install_requires=[ "incremental", "requests >= 2.1.0", + "hyperlink >= 19.0.0", "six", "Twisted[tls] >= 16.4.0 ; python_version < '3.7'", "Twisted[tls] >= 18.7.0 ; python_version >= '3.7'", @@ -53,4 +55,5 @@ license="MIT/X", url="https://github.com/twisted/treq", long_description=readme, + long_description_content_type='text/x-rst', ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/treq-20.3.0/src/treq/_version.py new/treq-20.4.1/src/treq/_version.py --- old/treq-20.3.0/src/treq/_version.py 2020-03-16 04:38:40.000000000 +0100 +++ new/treq-20.4.1/src/treq/_version.py 2020-04-17 06:56:14.000000000 +0200 @@ -7,5 +7,5 @@ from incremental import Version -__version__ = Version('treq', 20, 3, 0) +__version__ = Version('treq', 20, 4, 1) __all__ = ["__version__"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/treq-20.3.0/src/treq/client.py new/treq-20.4.1/src/treq/client.py --- old/treq-20.3.0/src/treq/client.py 2020-03-14 20:33:17.000000000 +0100 +++ new/treq-20.4.1/src/treq/client.py 2020-04-17 06:18:39.000000000 +0200 @@ -10,9 +10,7 @@ from twisted.python.components import proxyForInterface from twisted.python.compat import _PY3, unicode from twisted.python.filepath import FilePath -from twisted.python.url import URL - -from twisted.web.http import urlparse +from hyperlink import parse as _parse_url from twisted.web.http_headers import Headers from twisted.web.iweb import IBodyProducer, IResponse @@ -36,16 +34,25 @@ from requests.cookies import cookiejar_from_dict, merge_cookies if _PY3: - from urllib.parse import urlunparse, urlencode as _urlencode + from urllib.parse import urlencode as _urlencode def urlencode(query, doseq): return _urlencode(query, doseq).encode('ascii') from http.cookiejar import CookieJar else: from cookielib import CookieJar - from urlparse import urlunparse from urllib import urlencode +try: + # The old location was quixotically deprecated and might actually be + # removed in 3.10, maybe. + # + # See https://github.com/html5lib/html5lib-python/issues/419 for more of + # this tale of woe. + from collections.abc import Mapping +except ImportError: + from collections import Mapping + class _BodyBufferingProtocol(proxyForInterface(IProtocol)): def __init__(self, original, buffer, finished): @@ -147,14 +154,20 @@ """ method = method.encode('ascii').upper() + if isinstance(url, unicode): + parsed_url = _parse_url(url) + else: + parsed_url = _parse_url(url.decode('ascii')) + # Join parameters provided in the URL # and the ones passed as argument. params = kwargs.get('params') if params: - url = _combine_query_params(url, params) + parsed_url = parsed_url.replace( + query=parsed_url.query + tuple(_coerced_query_params(params)) + ) - if isinstance(url, unicode): - url = URL.fromText(url).asURI().asText().encode('ascii') + url = parsed_url.to_uri().to_text().encode('ascii') # Convert headers dictionary to # twisted raw headers format. @@ -304,19 +317,41 @@ yield (param, (file_name, content_type, IBodyProducer(fobj))) -def _combine_query_params(url, params): - parsed_url = urlparse(url.encode('ascii')) - - qs = [] +def _coerced_query_params(params): + """ + Carefully coerce *params* in the same way as `urllib.parse.urlencode()` - if parsed_url.query: - qs.extend([parsed_url.query, b'&']) + Parameter names and values are coerced to unicode. As a special case, + `bytes` are decoded as ASCII. - qs.append(urlencode(params, doseq=True)) + :param params: + A mapping or sequence of (name, value) two-tuples. The value may be + a list or tuple of multiple values. Names and values may be pretty much + any type. + + :returns: + A generator that yields two-tuples containing text strings. + :rtype: + Iterator[Tuple[Text, Text]] + """ + if isinstance(params, Mapping): + items = params.items() + else: + items = params - return urlunparse((parsed_url[0], parsed_url[1], - parsed_url[2], parsed_url[3], - b''.join(qs), parsed_url[5])) + for key, values in items: + if isinstance(key, bytes): + key = key.decode('ascii') + elif not isinstance(key, unicode): + key = unicode(key) + if not isinstance(values, (list, tuple)): + values = [values] + for value in values: + if isinstance(value, bytes): + value = value.decode('ascii') + elif not isinstance(value, unicode): + value = unicode(value) + yield key, value def _from_bytes(orig_bytes): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/treq-20.3.0/src/treq/test/test_client.py new/treq-20.4.1/src/treq/test/test_client.py --- old/treq-20.3.0/src/treq/test/test_client.py 2020-03-14 20:33:17.000000000 +0100 +++ new/treq-20.4.1/src/treq/test/test_client.py 2020-04-17 06:18:39.000000000 +0200 @@ -49,6 +49,18 @@ b'GET', b'http://xn--bea.net', Headers({b'accept-encoding': [b'gzip']}), None) + def test_request_uri_idn_params(self): + """ + A URL that contains non-ASCII characters can be augmented with + querystring parameters. + + This reproduces treq #264. + """ + self.client.request('GET', u'http://č.net', params={'foo': 'bar'}) + self.agent.request.assert_called_once_with( + b'GET', b'http://xn--bea.net/?foo=bar', + Headers({b'accept-encoding': [b'gzip']}), None) + def test_request_case_insensitive_methods(self): self.client.request('gEt', 'http://example.com/') self.agent.request.assert_called_once_with( @@ -71,6 +83,89 @@ b'GET', b'http://example.com/?foo=bar', Headers({b'accept-encoding': [b'gzip']}), None) + def test_request_tuple_query_value_coercion(self): + """ + treq coerces non-string values passed to *params* like + `urllib.urlencode()` + """ + self.client.request('GET', 'http://example.com/', params=[ + ('text', u'A\u03a9'), + ('text-seq', [u'A\u03a9']), + ('bytes', [b'ascii']), + ('bytes-seq', [b'ascii']), + ('native', ['native']), + ('native-seq', ['aa', 'bb']), + ('int', 1), + ('int-seq', (1, 2, 3)), + ('none', None), + ('none-seq', [None, None]), + ]) + + self.agent.request.assert_called_once_with( + b'GET', + ( + b'http://example.com/?' + b'text=A%CE%A9&text-seq=A%CE%A9' + b'&bytes=ascii&bytes-seq=ascii' + b'&native=native&native-seq=aa&native-seq=bb' + b'&int=1&int-seq=1&int-seq=2&int-seq=3' + b'&none=None&none-seq=None&none-seq=None' + ), + Headers({b'accept-encoding': [b'gzip']}), + None, + ) + + def test_request_tuple_query_param_coercion(self): + """ + treq coerces non-string param names passed to *params* like + `urllib.urlencode()` + """ + self.client.request('GET', 'http://example.com/', params=[ + (u'text', u'A\u03a9'), + (b'bytes', ['ascii']), + ('native', 'native'), + (1, 'int'), + (None, ['none']), + ]) + + self.agent.request.assert_called_once_with( + b'GET', + ( + b'http://example.com/' + b'?text=A%CE%A9&bytes=ascii' + b'&native=native&1=int&None=none' + ), + Headers({b'accept-encoding': [b'gzip']}), + None, + ) + + def test_request_query_param_seps(self): + """ + When the characters ``&`` and ``#`` are passed to *params* as param + names or values they are percent-escaped in the URL. + + This reproduces https://github.com/twisted/treq/issues/282 + """ + self.client.request('GET', 'http://example.com/', params=( + ('ampersand', '&'), + ('&', 'ampersand'), + ('octothorpe', '#'), + ('#', 'octothorpe'), + )) + + self.agent.request.assert_called_once_with( + b'GET', + ( + b'http://example.com/' + b'?ampersand=%26' + b'&%26=ampersand' + b'&octothorpe=%23' + b'&%23=octothorpe' + ), + Headers({b'accept-encoding': [b'gzip']}), + None, + ) + def test_request_merge_query_params(self): self.client.request('GET', 'http://example.com/?baz=bax', params={'foo': ['bar', 'baz']}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/treq-20.3.0/src/treq.egg-info/PKG-INFO new/treq-20.4.1/src/treq.egg-info/PKG-INFO --- old/treq-20.3.0/src/treq.egg-info/PKG-INFO 2020-03-16 04:39:35.000000000 +0100 +++ new/treq-20.4.1/src/treq.egg-info/PKG-INFO 2020-04-17 07:01:10.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: treq -Version: 20.3.0 +Version: 20.4.1 Summary: High-level Twisted HTTP Client API Home-page: https://github.com/twisted/treq Author: David Reid @@ -79,6 +79,8 @@ Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy +Description-Content-Type: text/x-rst Provides-Extra: dev diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/treq-20.3.0/src/treq.egg-info/SOURCES.txt new/treq-20.4.1/src/treq.egg-info/SOURCES.txt --- old/treq-20.3.0/src/treq.egg-info/SOURCES.txt 2020-03-16 04:39:35.000000000 +0100 +++ new/treq-20.4.1/src/treq.egg-info/SOURCES.txt 2020-04-17 07:01:10.000000000 +0200 @@ -20,6 +20,7 @@ docs/examples/basic_auth.py docs/examples/basic_get.py docs/examples/basic_post.py +docs/examples/custom_agent.py docs/examples/disable_redirects.py docs/examples/download_file.py docs/examples/iresource.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/treq-20.3.0/src/treq.egg-info/requires.txt new/treq-20.4.1/src/treq.egg-info/requires.txt --- old/treq-20.3.0/src/treq.egg-info/requires.txt 2020-03-16 04:39:35.000000000 +0100 +++ new/treq-20.4.1/src/treq.egg-info/requires.txt 2020-04-17 07:01:10.000000000 +0200 @@ -1,5 +1,6 @@ incremental requests>=2.1.0 +hyperlink>=19.0.0 six attrs