Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-oslo.utils for openSUSE:Factory checked in at 2021-05-10 15:37:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-oslo.utils (Old) and /work/SRC/openSUSE:Factory/.python-oslo.utils.new.2988 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-oslo.utils" Mon May 10 15:37:42 2021 rev:24 rq:889999 version:4.8.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-oslo.utils/python-oslo.utils.changes 2020-10-26 16:18:01.611017820 +0100 +++ /work/SRC/openSUSE:Factory/.python-oslo.utils.new.2988/python-oslo.utils.changes 2021-05-10 15:39:53.625438103 +0200 @@ -1,0 +2,15 @@ +Sun May 2 17:33:34 UTC 2021 - cloud-de...@suse.de + +- update to version 4.8.0 + - Add a ``strict`` flag allowing users to restrict validation of IPv4 format + - Use py3 as the default runtime for tox + - Update master for stable/victoria + - Add function to encapsule md5 for FIPS systems + - Use TOX_CONSTRAINTS_FILE + - Add Python3 wallaby unit tests + - Remove all usage of six library + - Dropping lower constraints testing + - Adding pre-commit + - Add Python3 victoria unit tests + +------------------------------------------------------------------- Old: ---- oslo.utils-4.6.0.tar.gz New: ---- oslo.utils-4.8.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-oslo.utils.spec ++++++ --- /var/tmp/diff_new_pack.f9OPWa/_old 2021-05-10 15:39:54.125436057 +0200 +++ /var/tmp/diff_new_pack.f9OPWa/_new 2021-05-10 15:39:54.129436042 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-oslo.utils # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,13 +17,13 @@ Name: python-oslo.utils -Version: 4.6.0 +Version: 4.8.0 Release: 0 Summary: OpenStack Utils Library License: Apache-2.0 Group: Development/Languages/Python -URL: https://launchpad.net/oslo.utils -Source0: https://files.pythonhosted.org/packages/source/o/oslo.utils/oslo.utils-4.6.0.tar.gz +URL: https://docs.openstack.org/oslo.utils +Source0: https://files.pythonhosted.org/packages/source/o/oslo.utils/oslo.utils-4.8.0.tar.gz BuildRequires: openstack-macros BuildRequires: python3-Babel BuildRequires: python3-ddt @@ -50,7 +50,6 @@ %package -n python3-oslo.utils Summary: OpenStack Utils Library -Group: Development/Languages/Python Requires: python3-debtcollector >= 1.2.0 Requires: python3-iso8601 >= 0.1.11 Requires: python3-netaddr >= 0.7.18 @@ -58,7 +57,7 @@ Requires: python3-oslo.i18n >= 3.15.3 Requires: python3-pyparsing >= 2.1.0 Requires: python3-pytz >= 2013.6 -Requires: python3-six >= 1.10.0 +Requires: python3-six %description -n python3-oslo.utils The oslo.utils library provides support for common utility type functions, @@ -68,7 +67,6 @@ %package -n python-oslo.utils-doc Summary: Documentation for OpenStack utils library -Group: Development/Languages/Python BuildRequires: python3-Sphinx BuildRequires: python3-openstackdocstheme @@ -76,7 +74,7 @@ Documentation for OpenStack utils library. %prep -%autosetup -p1 -n oslo.utils-4.6.0 +%autosetup -p1 -n oslo.utils-4.8.0 %py_req_cleanup @@ -87,7 +85,7 @@ %py3_install # generate html docs -PBR_VERSION=4.6.0 %sphinx_build -b html doc/source doc/build/html +PBR_VERSION=4.8.0 %sphinx_build -b html doc/source doc/build/html # remove the sphinx-build leftovers rm -rf doc/build/html/.{doctrees,buildinfo} ++++++ _service ++++++ --- /var/tmp/diff_new_pack.f9OPWa/_old 2021-05-10 15:39:54.157435926 +0200 +++ /var/tmp/diff_new_pack.f9OPWa/_new 2021-05-10 15:39:54.157435926 +0200 @@ -1,8 +1,8 @@ <services> <service mode="disabled" name="renderspec"> - <param name="input-template">https://opendev.org/openstack/rpm-packaging/raw/branch/stable/victoria/openstack/oslo.utils/oslo.utils.spec.j2</param> + <param name="input-template">https://opendev.org/openstack/rpm-packaging/raw/branch/stable/wallaby/openstack/oslo.utils/oslo.utils.spec.j2</param> <param name="output-name">python-oslo.utils.spec</param> - <param name="requirements">https://opendev.org/openstack/oslo.utils/raw/branch/stable/victoria/requirements.txt</param> + <param name="requirements">https://opendev.org/openstack/oslo.utils/raw/branch/stable/wallaby/requirements.txt</param> <param name="changelog-email">cloud-de...@suse.de</param> <param name="changelog-provider">gh,openstack,oslo.utils</param> </service> ++++++ oslo.utils-4.6.0.tar.gz -> oslo.utils-4.8.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/.pre-commit-config.yaml new/oslo.utils-4.8.0/.pre-commit-config.yaml --- old/oslo.utils-4.6.0/.pre-commit-config.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/oslo.utils-4.8.0/.pre-commit-config.yaml 2021-02-16 10:01:47.000000000 +0100 @@ -0,0 +1,35 @@ +# We from the Oslo project decided to pin repos based on the +# commit hash instead of the version tag to prevend arbitrary +# code from running in developer's machines. To update to a +# newer version, run `pre-commit autoupdate` and then replace +# the newer versions with their commit hash. + +default_language_version: + python: python3 + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: ebc15addedad713c86ef18ae9632c88e187dd0af # v3.1.0 + hooks: + - id: trailing-whitespace + # Replaces or checks mixed line ending + - id: mixed-line-ending + args: ['--fix', 'lf'] + exclude: '.*\.(svg)$' + # Forbid files which have a UTF-8 byte-order marker + - id: check-byte-order-marker + # Checks that non-binary executables have a proper shebang + - id: check-executables-have-shebangs + # Check for files that contain merge conflict strings. + - id: check-merge-conflict + # Check for debugger imports and py37+ breakpoint() + # calls in python source + - id: debug-statements + - id: check-yaml + files: .*\.(yaml|yml)$ + - repo: https://gitlab.com/pycqa/flake8 + rev: 181bb46098dddf7e2d45319ea654b4b4d58c2840 # 3.8.3 + hooks: + - id: flake8 + additional_dependencies: + - hacking>=3.0.1,<3.1.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/.zuul.yaml new/oslo.utils-4.8.0/.zuul.yaml --- old/oslo.utils-4.6.0/.zuul.yaml 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/.zuul.yaml 2021-02-16 10:01:47.000000000 +0100 @@ -2,8 +2,7 @@ templates: - check-requirements - lib-forward-testing-python3 - - openstack-lower-constraints-jobs - - openstack-python3-ussuri-jobs + - openstack-python3-wallaby-jobs - periodic-stable-jobs - publish-openstack-docs-pti - release-notes-jobs-python3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/AUTHORS new/oslo.utils-4.8.0/AUTHORS --- old/oslo.utils-4.6.0/AUTHORS 2020-09-11 21:24:01.000000000 +0200 +++ new/oslo.utils-4.8.0/AUTHORS 2021-02-16 10:02:17.000000000 +0100 @@ -1,6 +1,7 @@ Abhishek Chanda <abhis...@cloudscaling.com> Abhishek Kekane <abhishek.kek...@nttdata.com> Adam Harwell <flux.a...@gmail.com> +Ade Lee <a...@redhat.com> Akihiro Motoki <amot...@gmail.com> Akihiro Motoki <mot...@da.jp.nec.com> Albert White <albert.wh...@oracle.com> @@ -153,6 +154,7 @@ dharmendra <dharmendra.kushw...@nectechnologies.in> ekudryashova <ekudryash...@mirantis.com> gecong1973 <ge.c...@zte.com.cn> +haixin <hai...@inspur.com> hnyang <hny...@fiberhome.com> howardlee <lihongwe...@inspur.com> jacky06 <zhang....@99cloud.net> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/ChangeLog new/oslo.utils-4.8.0/ChangeLog --- old/oslo.utils-4.6.0/ChangeLog 2020-09-11 21:24:00.000000000 +0200 +++ new/oslo.utils-4.8.0/ChangeLog 2021-02-16 10:02:17.000000000 +0100 @@ -1,10 +1,29 @@ CHANGES ======= +4.8.0 +----- + +* Add a \`\`strict\`\` flag allowing users to restrict validation of IPv4 format +* Use TOX\_CONSTRAINTS\_FILE +* Dropping lower constraints testing +* Use TOX\_CONSTRAINTS\_FILE +* Use py3 as the default runtime for tox +* Remove all usage of six library + +4.7.0 +----- + +* Add function to encapsule md5 for FIPS systems +* Add Python3 wallaby unit tests +* Update master for stable/victoria +* Adding pre-commit + 4.6.0 ----- * [goal] Migrate testing to ubuntu focal +* Add Python3 victoria unit tests * Fix is\_same\_callback() testing for python3.8 4.5.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/PKG-INFO new/oslo.utils-4.8.0/PKG-INFO --- old/oslo.utils-4.6.0/PKG-INFO 2020-09-11 21:24:01.000000000 +0200 +++ new/oslo.utils-4.8.0/PKG-INFO 2021-02-16 10:02:17.815975400 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: oslo.utils -Version: 4.6.0 +Version: 4.8.0 Summary: Oslo Utility library Home-page: https://docs.openstack.org/oslo.utils/latest/ Author: OpenStack diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/doc/source/conf.py new/oslo.utils-4.8.0/doc/source/conf.py --- old/oslo.utils-4.6.0/doc/source/conf.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/doc/source/conf.py 2021-02-16 10:01:47.000000000 +0100 @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2020 Red Hat, Inc. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -75,6 +77,3 @@ u'%s Documentation' % project, u'OpenStack Foundation', 'manual'), ] - -# Example configuration for intersphinx: refer to the Python standard library. -#intersphinx_mapping = {'http://docs.python.org/': None} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/lower-constraints.txt new/oslo.utils-4.8.0/lower-constraints.txt --- old/oslo.utils-4.6.0/lower-constraints.txt 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/lower-constraints.txt 2021-02-16 10:01:47.000000000 +0100 @@ -29,7 +29,6 @@ requests==2.14.2 requestsexceptions==1.2.0 rfc3986==0.3.1 -six==1.10.0 smmap==0.9.0 stestr==2.0.0 stevedore==1.20.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo.utils.egg-info/PKG-INFO new/oslo.utils-4.8.0/oslo.utils.egg-info/PKG-INFO --- old/oslo.utils-4.6.0/oslo.utils.egg-info/PKG-INFO 2020-09-11 21:24:01.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo.utils.egg-info/PKG-INFO 2021-02-16 10:02:17.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: oslo.utils -Version: 4.6.0 +Version: 4.8.0 Summary: Oslo Utility library Home-page: https://docs.openstack.org/oslo.utils/latest/ Author: OpenStack diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo.utils.egg-info/SOURCES.txt new/oslo.utils-4.8.0/oslo.utils.egg-info/SOURCES.txt --- old/oslo.utils-4.6.0/oslo.utils.egg-info/SOURCES.txt 2020-09-11 21:24:01.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo.utils.egg-info/SOURCES.txt 2021-02-16 10:02:17.000000000 +0100 @@ -1,5 +1,6 @@ .coveragerc .mailmap +.pre-commit-config.yaml .stestr.conf .zuul.yaml AUTHORS @@ -93,8 +94,10 @@ oslo_utils/tests/fake/__init__.py oslo_utils/tests/fake/v2/__init__.py oslo_utils/tests/fake/v2/dummpy.py +releasenotes/notes/add-md5-wrapper-7bf81c2464a7a224.yaml releasenotes/notes/add-methods-for-json-yaml-file-check-746dca0a11c2f9c9.yaml releasenotes/notes/add-reno-350f5f34f794fb5e.yaml +releasenotes/notes/allow-to-convert-ipv4-address-from-text-to-binary-8c46ad2d9989e8c5.yaml releasenotes/notes/bump-up-port-range-f774a16336158339.yaml releasenotes/notes/drop-python27-support-f97f680651693b47.yaml releasenotes/notes/image-utils-handle-scientific-notation-6f65d46e9c8c8f8c.yaml @@ -112,6 +115,7 @@ releasenotes/source/train.rst releasenotes/source/unreleased.rst releasenotes/source/ussuri.rst +releasenotes/source/victoria.rst releasenotes/source/_static/.placeholder releasenotes/source/_templates/.placeholder releasenotes/source/locale/en_GB/LC_MESSAGES/releasenotes.po diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo.utils.egg-info/pbr.json new/oslo.utils-4.8.0/oslo.utils.egg-info/pbr.json --- old/oslo.utils-4.6.0/oslo.utils.egg-info/pbr.json 2020-09-11 21:24:01.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo.utils.egg-info/pbr.json 2021-02-16 10:02:17.000000000 +0100 @@ -1 +1 @@ -{"git_version": "91497da", "is_release": true} \ No newline at end of file +{"git_version": "3288539", "is_release": true} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo.utils.egg-info/requires.txt new/oslo.utils-4.8.0/oslo.utils.egg-info/requires.txt --- old/oslo.utils-4.6.0/oslo.utils.egg-info/requires.txt 2020-09-11 21:24:01.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo.utils.egg-info/requires.txt 2021-02-16 10:02:17.000000000 +0100 @@ -7,4 +7,3 @@ pbr!=2.1.0,>=2.0.0 pyparsing>=2.1.0 pytz>=2013.6 -six>=1.10.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/dictutils.py new/oslo.utils-4.8.0/oslo_utils/dictutils.py --- old/oslo.utils-4.6.0/oslo_utils/dictutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/dictutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import six - def flatten_dict_to_keypairs(d, separator=':'): """Generator that produces sequence of keypairs for nested dictionaries. @@ -22,7 +20,7 @@ :param d: dictionaries which may be nested :param separator: symbol between names """ - for name, value in sorted(six.iteritems(d)): + for name, value in sorted(iter(d.items())): if isinstance(value, dict): for subname, subvalue in flatten_dict_to_keypairs(value, separator): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/encodeutils.py new/oslo.utils-4.8.0/oslo_utils/encodeutils.py --- old/oslo.utils-4.6.0/oslo_utils/encodeutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/encodeutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -15,8 +15,6 @@ import sys -import six - # NOTE(blk-u): This provides a symbol that can be overridden just for this # module during testing. sys.getfilesystemencoding() is called by coverage so @@ -35,10 +33,10 @@ representation of it. :raises TypeError: If text is not an instance of str """ - if not isinstance(text, (six.string_types, six.binary_type)): + if not isinstance(text, (str, bytes)): raise TypeError("%s can't be decoded" % type(text)) - if isinstance(text, six.text_type): + if isinstance(text, str): return text if not incoming: @@ -81,7 +79,7 @@ See also to_utf8() function which is simpler and don't depend on the locale encoding. """ - if not isinstance(text, (six.string_types, six.binary_type)): + if not isinstance(text, (str, bytes)): raise TypeError("%s can't be encoded" % type(text)) if not incoming: @@ -94,7 +92,7 @@ if hasattr(encoding, 'lower'): encoding = encoding.lower() - if isinstance(text, six.text_type): + if isinstance(text, str): return text.encode(encoding, errors) elif text and encoding != incoming: # Decode text before encoding it with `encoding` @@ -111,9 +109,9 @@ .. versionadded:: 3.5 """ - if isinstance(text, six.binary_type): + if isinstance(text, bytes): return text - elif isinstance(text, six.text_type): + elif isinstance(text, str): return text.encode('utf-8') else: raise TypeError("bytes or Unicode expected, got %s" @@ -133,24 +131,6 @@ .. versionadded:: 1.6 """ msg = None - if six.PY2: - # First try by calling the unicode type constructor. We should try - # unicode() before exc.__unicode__() because subclasses of unicode can - # be easily casted to unicode, whereas they have no __unicode__() - # method. - try: - msg = unicode(exc) # NOQA - except UnicodeError: - # unicode(exc) fail with UnicodeDecodeError on Python 2 if - # exc.__unicode__() or exc.__str__() returns a bytes string not - # decodable from the default encoding (ASCII) - if hasattr(exc, '__unicode__'): - # Call directly the __unicode__() method to avoid - # the implicit decoding from the default encoding - try: - msg = exc.__unicode__() - except UnicodeError: # nosec - pass if msg is None: # Don't call directly str(exc), because it fails with @@ -158,7 +138,7 @@ # string not encodable to the default encoding (ASCII) msg = exc.__str__() - if isinstance(msg, six.text_type): + if isinstance(msg, str): # This should be the default path on Python 3 and an *optional* path # on Python 2 (if for some reason the exception message was already # in unicode instead of the more typical bytes string); so avoid diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/excutils.py new/oslo.utils-4.8.0/oslo_utils/excutils.py --- old/oslo.utils-4.6.0/oslo_utils/excutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/excutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -18,14 +18,13 @@ """ import functools +import io import logging import os import sys import time import traceback -import six - from oslo_utils import encodeutils from oslo_utils import reflection @@ -70,7 +69,7 @@ if indent < 0: raise ValueError("Provided 'indent' must be greater than" " or equal to zero instead of %s" % indent) - buf = six.StringIO() + buf = io.StringIO() if show_root_class: buf.write(reflection.get_class_name(self, fully_qualified=False)) buf.write(": ") @@ -140,7 +139,7 @@ # Leave no references around (especially with regards to # tracebacks and any variables that it retains internally). del(exc_type, exc, exc_tb) - six.raise_from(exc_cls(message, *args, **kwargs), kwargs.get('cause')) + raise exc_cls(message, *args, **kwargs) from kwargs.get('cause') class save_and_reraise_exception(object): @@ -193,7 +192,15 @@ if self.type_ is None and self.value is None: raise RuntimeError("There is no (currently) captured exception" " to force the reraising of") - six.reraise(self.type_, self.value, self.tb) + try: + if self.value is None: + self.value = self.type_() + if self.value.__traceback__ is not self.tb: + raise self.value.with_traceback(self.tb) + raise self.value + finally: + self.value = None + self.tb = None def capture(self, check=True): (type_, value, tb) = sys.exc_info() @@ -240,7 +247,7 @@ retry_delay = max(0.0, float(kwargs.get('retry_delay', 1.0))) same_log_delay = max(0.0, float(kwargs.get('same_log_delay', 60.0))) - @six.wraps(infunc) + @functools.wraps(infunc) def wrapper(*args, **kwargs): last_exc_message = None same_failure_count = 0 @@ -339,7 +346,15 @@ try: if not self._should_ignore_ex(ex): if exc_val is ex: - six.reraise(exc_type, exc_val, traceback) + try: + if exc_val is None: + exc_val = exc_type() + if exc_val.__traceback__ is not traceback: + raise exc_val.with_traceback(traceback) + raise exc_val + finally: + exc_val = None + traceback = None else: raise ex finally: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/netutils.py new/oslo.utils-4.8.0/oslo_utils/netutils.py --- old/oslo.utils-4.6.0/oslo_utils/netutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/netutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -21,11 +21,11 @@ import os import re import socket +from urllib import parse import netaddr +from netaddr.core import INET_PTON import netifaces -import six -from six.moves.urllib import parse from oslo_utils._i18n import _ @@ -82,17 +82,43 @@ return (host, None if port is None else int(port)) -def is_valid_ipv4(address): +def is_valid_ipv4(address, strict=None): """Verify that address represents a valid IPv4 address. :param address: Value to verify :type address: string + :param strict: flag allowing users to restrict validation + to IP addresses in presentation format (``a.b.c.d``) as opposed to + address format (``a.b.c.d``, ``a.b.c``, ``a.b``, ``a``). + :type flags: bool :returns: bool .. versionadded:: 1.1 - """ + .. versionchanged:: 4.8.0 + Allow to restrict validation to IP addresses in presentation format + (``a.b.c.d``) as opposed to address format + (``a.b.c.d``, ``a.b.c``, ``a.b``, ``a``). + """ + if strict is not None: + flag = INET_PTON if strict else 0 + try: + return netaddr.valid_ipv4(address, flags=flag) + except netaddr.AddrFormatError: + return False + + # non strict mode try: - return netaddr.valid_ipv4(address) + if netaddr.valid_ipv4(address, flags=INET_PTON): + return True + else: + if netaddr.valid_ipv4(address): + LOG.warn( + 'Converting in non strict mode is deprecated. ' + 'You should pass strict=False if you want to ' + 'preserve legacy behavior') + return True + else: + return False except netaddr.AddrFormatError: return False @@ -284,7 +310,7 @@ .. versionadded:: 3.17 """ m = "[0-9a-f]{2}(:[0-9a-f]{2}){5}$" - return (isinstance(address, six.string_types) and + return (isinstance(address, str) and re.match(m, address.lower())) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/reflection.py new/oslo.utils-4.8.0/oslo_utils/reflection.py --- old/oslo.utils-4.6.0/oslo_utils/reflection.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/reflection.py 2021-02-16 10:01:47.000000000 +0100 @@ -22,10 +22,9 @@ import inspect import logging +import operator import types -import six - try: _TYPE_TYPE = types.TypeType except AttributeError: @@ -40,16 +39,9 @@ LOG = logging.getLogger(__name__) -if six.PY3: - Parameter = inspect.Parameter - Signature = inspect.Signature - get_signature = inspect.signature -else: - # Provide an equivalent but use funcsigs instead... - import funcsigs - Parameter = funcsigs.Parameter - Signature = funcsigs.Signature - get_signature = funcsigs.signature +Parameter = inspect.Parameter +Signature = inspect.Signature +get_signature = inspect.signature def get_members(obj, exclude_hidden=True): @@ -85,7 +77,7 @@ if inspect.ismethod(obj): obj = get_method_self(obj) - if not isinstance(obj, six.class_types): + if not isinstance(obj, type): obj = type(obj) if truncate_builtins: try: @@ -109,7 +101,7 @@ in order of method resolution (mro). If up_to parameter is provided, only name of classes that are sublcasses to that class are returned. """ - if not isinstance(obj, six.class_types): + if not isinstance(obj, type): obj = type(obj) for cls in obj.mro(): if issubclass(cls, up_to): @@ -126,7 +118,7 @@ method_self = get_method_self(function) if method_self is not None: # This is a bound method. - if isinstance(method_self, six.class_types): + if isinstance(method_self, type): # This is a bound class method. im_class = method_self else: @@ -163,7 +155,7 @@ if not inspect.ismethod(method): return None try: - return six.get_method_self(method) + return operator.attrgetter("__self__")(method) except AttributeError: return None @@ -203,8 +195,8 @@ # another object if the objects have __eq__ methods that return true # (when in fact it is a different bound method). Python u so crazy! try: - self1 = six.get_method_self(callback1) - self2 = six.get_method_self(callback2) + self1 = operator.attrgetter("__self__")(callback1) + self2 = operator.attrgetter("__self__")(callback2) return self1 is self2 except AttributeError: # nosec pass @@ -231,8 +223,8 @@ are not included into output. """ sig = get_signature(function) - function_args = list(six.iterkeys(sig.parameters)) - for param_name, p in six.iteritems(sig.parameters): + function_args = list(iter(sig.parameters.keys())) + for param_name, p in iter(sig.parameters.items()): if (p.kind in (Parameter.VAR_POSITIONAL, Parameter.VAR_KEYWORD) or (required_only and p.default is not Parameter.empty)): function_args.remove(param_name) @@ -243,4 +235,4 @@ """Returns ``True`` if function accepts kwargs otherwise ``False``.""" sig = get_signature(function) return any(p.kind == Parameter.VAR_KEYWORD - for p in six.itervalues(sig.parameters)) + for p in iter(sig.parameters.values())) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/secretutils.py new/oslo.utils-4.8.0/oslo_utils/secretutils.py --- old/oslo.utils-4.6.0/oslo_utils/secretutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/secretutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -18,6 +18,7 @@ .. versionadded:: 3.5 """ +import hashlib import hmac @@ -44,3 +45,23 @@ constant_time_compare = hmac.compare_digest except AttributeError: constant_time_compare = _constant_time_compare + +try: + _ = hashlib.md5(usedforsecurity=False) # nosec + + def md5(string=b'', usedforsecurity=True): + """Return an md5 hashlib object using usedforsecurity parameter + + For python distributions that support the usedforsecurity keyword + parameter, this passes the parameter through as expected. + See https://bugs.python.org/issue9216 + """ + return hashlib.md5(string, usedforsecurity=usedforsecurity) # nosec +except TypeError: + def md5(string=b'', usedforsecurity=True): + """Return an md5 hashlib object without usedforsecurity parameter + + For python distributions that do not yet support this keyword + parameter, we drop the parameter + """ + return hashlib.md5(string) # nosec diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/strutils.py new/oslo.utils-4.8.0/oslo_utils/strutils.py --- old/oslo.utils-4.6.0/oslo_utils/strutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/strutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -21,10 +21,9 @@ import math import re import unicodedata +import urllib import pyparsing as pp -import six -from six.moves import urllib from oslo_utils._i18n import _ from oslo_utils import encodeutils @@ -138,8 +137,8 @@ """ if isinstance(subject, bool): return subject - if not isinstance(subject, six.string_types): - subject = six.text_type(subject) + if not isinstance(subject, str): + subject = str(subject) lowered = subject.strip().lower() @@ -324,7 +323,7 @@ """ try: - message = six.text_type(message) + message = str(message) except UnicodeDecodeError: # nosec # NOTE(jecarey): Temporary fix to handle cases where message is a # byte string. A better solution will be provided in Kilo. @@ -411,7 +410,7 @@ # NOTE(jlvillal): Check to see if anything in the dictionary 'key' # contains any key specified in _SANITIZE_KEYS. k_matched = False - if isinstance(k, six.string_types): + if isinstance(k, str): for sani_key in _SANITIZE_KEYS: if sani_key in k.lower(): out[k] = secret @@ -420,7 +419,7 @@ if not k_matched: # We did not find a match for the key name in the # _SANITIZE_KEYS, so we fall through to here - if isinstance(v, six.string_types): + if isinstance(v, str): out[k] = mask_password(v, secret=secret) else: # Just leave it alone. @@ -438,7 +437,7 @@ .. versionadded:: 1.1 """ try: - return six.text_type(int(val)) == six.text_type(val) + return str(int(val)) == str(val) except (TypeError, ValueError): return False @@ -457,7 +456,7 @@ if name is None: name = value - if not isinstance(value, six.string_types): + if not isinstance(value, str): msg = _("%s is not a string or unicode") % name raise TypeError(msg) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/tests/test_eventletutils.py new/oslo.utils-4.8.0/oslo_utils/tests/test_eventletutils.py --- old/oslo.utils-4.6.0/oslo_utils/tests/test_eventletutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/tests/test_eventletutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -19,7 +19,6 @@ import eventlet from eventlet import greenthread from oslotest import base as test_base -import six from oslo_utils import eventletutils @@ -44,7 +43,7 @@ self.assertEqual(1, len(capture)) w = capture[0] self.assertEqual(RuntimeWarning, w.category) - self.assertIn('os', six.text_type(w.message)) + self.assertIn('os', str(w.message)) @mock.patch("oslo_utils.eventletutils._patcher") def test_warning_not_patched_none_provided(self, mock_patcher): @@ -57,7 +56,7 @@ w = capture[0] self.assertEqual(RuntimeWarning, w.category) for m in eventletutils._ALL_PATCH: - self.assertIn(m, six.text_type(w.message)) + self.assertIn(m, str(w.message)) @mock.patch("oslo_utils.eventletutils._patcher") def test_warning_not_patched_all(self, mock_patcher): @@ -70,7 +69,7 @@ w = capture[0] self.assertEqual(RuntimeWarning, w.category) for m in eventletutils._ALL_PATCH: - self.assertIn(m, six.text_type(w.message)) + self.assertIn(m, str(w.message)) @mock.patch("oslo_utils.eventletutils._patcher") def test_no_warning(self, mock_patcher): @@ -118,7 +117,7 @@ w = capture[0] self.assertEqual(RuntimeWarning, w.category) for m in ['os', 'thread']: - self.assertNotIn(m, six.text_type(w.message)) + self.assertNotIn(m, str(w.message)) def test_invalid_patch_check(self): self.assertRaises(ValueError, @@ -133,10 +132,7 @@ self.assertIsInstance(e_event, eventletutils.EventletEvent) t_event = eventletutils.Event() - if six.PY3: - t_event_cls = threading.Event - else: - t_event_cls = threading._Event + t_event_cls = threading.Event self.assertIsInstance(t_event, t_event_cls) public_methods = [m for m in dir(t_event) if not m.startswith("_") and diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/tests/test_fileutils.py new/oslo.utils-4.8.0/oslo_utils/tests/test_fileutils.py --- old/oslo.utils-4.6.0/oslo_utils/tests/test_fileutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/tests/test_fileutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -26,7 +26,6 @@ import yaml from oslotest import base as test_base -import six from oslo_utils import fileutils @@ -131,7 +130,7 @@ def check_file_content(self, path): with open(path, 'r') as fd: ans = fd.read() - self.assertEqual(self.content, six.b(ans)) + self.assertEqual(self.content, ans.encode("latin-1")) def test_file_without_path_and_suffix(self): res = fileutils.write_to_tempfile(self.content) @@ -204,7 +203,7 @@ def check_file_content(self, content, path): with open(path, 'r') as fd: ans = fd.read() - self.assertEqual(content, six.b(ans)) + self.assertEqual(content, ans.encode("latin-1")) def test_compute_checksum_default_algorithm(self): path = fileutils.write_to_tempfile(self.content) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/tests/test_fixture.py new/oslo.utils-4.8.0/oslo_utils/tests/test_fixture.py --- old/oslo.utils-4.6.0/oslo_utils/tests/test_fixture.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/tests/test_fixture.py 2021-02-16 10:01:47.000000000 +0100 @@ -17,7 +17,6 @@ import datetime from oslotest import base as test_base -import six from oslo_utils import fixture from oslo_utils.fixture import uuidsentinel as uuids @@ -81,4 +80,4 @@ def test_with_underline_prefix(self): ex = self.assertRaises(AttributeError, getattr, uuids, '_foo') - self.assertIn("Sentinels must not start with _", six.text_type(ex)) + self.assertIn("Sentinels must not start with _", str(ex)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/tests/test_fnmatch.py new/oslo.utils-4.8.0/oslo_utils/tests/test_fnmatch.py --- old/oslo.utils-4.6.0/oslo_utils/tests/test_fnmatch.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/tests/test_fnmatch.py 2021-02-16 10:01:47.000000000 +0100 @@ -13,11 +13,9 @@ import fnmatch as standard_fnmatch import ntpath import posixpath -import sys from unittest import mock from oslotest import base -import six fnmatch = None @@ -48,12 +46,3 @@ fnmatch = standard_fnmatch self._test_fnmatch_posix_nt() - - with mock.patch.object(sys, 'version_info', new=(2, 7, 11)): - from oslo_utils import fnmatch as oslo_fnmatch - fnmatch = oslo_fnmatch - self._test_fnmatch_posix_nt() - - with mock.patch.object(sys, 'version_info', new=(2, 7, 0)): - six.moves.reload_module(oslo_fnmatch) - self._test_fnmatch_posix_nt() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/tests/test_netutils.py new/oslo.utils-4.8.0/oslo_utils/tests/test_netutils.py --- old/oslo.utils-4.6.0/oslo_utils/tests/test_netutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/tests/test_netutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -14,13 +14,13 @@ # under the License. import contextlib +import io import socket from unittest import mock import netaddr import netifaces from oslotest import base as test_base -import six from oslo_utils import netutils @@ -154,13 +154,52 @@ netutils.set_tcp_keepalive(mock_sock, False) self.assertEqual(1, len(mock_sock.mock_calls)) - def test_is_valid_ipv4(self): + @mock.patch.object(netutils, 'LOG', autospec=True) + def test_is_valid_ipv4(self, mock_log): + expected_log = 'Converting in non strict mode is deprecated. ' \ + 'You should pass strict=False if you want to preserve ' \ + 'legacy behavior' self.assertTrue(netutils.is_valid_ipv4('42.42.42.42')) self.assertFalse(netutils.is_valid_ipv4('-1.11.11.11')) self.assertFalse(netutils.is_valid_ipv4('')) + self.assertTrue(netutils.is_valid_ipv4('10')) + mock_log.warn.assert_called_with(expected_log) + mock_log.reset_mock() + self.assertTrue(netutils.is_valid_ipv4('10.10')) + mock_log.warn.assert_called_with(expected_log) + mock_log.reset_mock() + self.assertTrue(netutils.is_valid_ipv4('10.10.10')) + mock_log.warn.assert_called_with(expected_log) + mock_log.reset_mock() + self.assertTrue(netutils.is_valid_ipv4('10.10.10.10')) + mock_log.warn.assert_not_called() + mock_log.reset_mock() + self.assertFalse( + netutils.is_valid_ipv4('10', strict=True) + ) + self.assertFalse( + netutils.is_valid_ipv4('10.10', strict=True) + ) + self.assertFalse( + netutils.is_valid_ipv4('10.10.10', strict=True) + ) + mock_log.warn.assert_not_called() + mock_log.reset_mock() + self.assertTrue( + netutils.is_valid_ipv4('10', strict=False) + ) + self.assertTrue( + netutils.is_valid_ipv4('10.10', strict=False) + ) + self.assertTrue( + netutils.is_valid_ipv4('10.10.10', strict=False) + ) + mock_log.warn.assert_not_called() + mock_log.reset_mock() + def test_is_valid_ipv6(self): self.assertTrue(netutils.is_valid_ipv6('::1')) @@ -393,7 +432,7 @@ @contextlib.contextmanager def mock_file_content(content): # Allows StringIO to act like a context manager-enabled file. - yield six.StringIO(content) + yield io.StringIO(content) class TestIsIPv6Enabled(test_base.BaseTestCase): @@ -407,19 +446,19 @@ self.addCleanup(reset_detection_flag) @mock.patch('os.path.exists', return_value=True) - @mock.patch('six.moves.builtins.open', return_value=mock_file_content('0')) + @mock.patch('builtins.open', return_value=mock_file_content('0')) def test_enabled(self, mock_open, exists): enabled = netutils.is_ipv6_enabled() self.assertTrue(enabled) @mock.patch('os.path.exists', return_value=True) - @mock.patch('six.moves.builtins.open', return_value=mock_file_content('1')) + @mock.patch('builtins.open', return_value=mock_file_content('1')) def test_disabled(self, mock_open, exists): enabled = netutils.is_ipv6_enabled() self.assertFalse(enabled) @mock.patch('os.path.exists', return_value=False) - @mock.patch('six.moves.builtins.open', + @mock.patch('builtins.open', side_effect=AssertionError('should not read')) def test_disabled_non_exists(self, mock_open, exists): enabled = netutils.is_ipv6_enabled() @@ -429,14 +468,14 @@ def test_memoize_enabled(self, exists): # Reset the flag to appear that we haven't looked for it yet. netutils._IS_IPV6_ENABLED = None - with mock.patch('six.moves.builtins.open', + with mock.patch('builtins.open', return_value=mock_file_content('0')) as mock_open: enabled = netutils.is_ipv6_enabled() self.assertTrue(mock_open.called) self.assertTrue(netutils._IS_IPV6_ENABLED) self.assertTrue(enabled) # The second call should not use open again - with mock.patch('six.moves.builtins.open', + with mock.patch('builtins.open', side_effect=AssertionError('should not be called')): enabled = netutils.is_ipv6_enabled() self.assertTrue(enabled) @@ -445,18 +484,18 @@ def test_memoize_disabled(self, exists): # Reset the flag to appear that we haven't looked for it yet. netutils._IS_IPV6_ENABLED = None - with mock.patch('six.moves.builtins.open', + with mock.patch('builtins.open', return_value=mock_file_content('1')): enabled = netutils.is_ipv6_enabled() self.assertFalse(enabled) # The second call should not use open again - with mock.patch('six.moves.builtins.open', + with mock.patch('builtins.open', side_effect=AssertionError('should not be called')): enabled = netutils.is_ipv6_enabled() self.assertFalse(enabled) @mock.patch('os.path.exists', return_value=False) - @mock.patch('six.moves.builtins.open', + @mock.patch('builtins.open', side_effect=AssertionError('should not read')) def test_memoize_not_exists(self, mock_open, exists): # Reset the flag to appear that we haven't looked for it yet. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/tests/test_reflection.py new/oslo.utils-4.8.0/oslo_utils/tests/test_reflection.py --- old/oslo.utils-4.6.0/oslo_utils/tests/test_reflection.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/tests/test_reflection.py 2021-02-16 10:01:47.000000000 +0100 @@ -14,26 +14,21 @@ # License for the specific language governing permissions and limitations # under the License. +import functools import sys from oslotest import base as test_base -import six -import testtools from oslo_utils import reflection -if six.PY3: - RUNTIME_ERROR_CLASSES = ['RuntimeError', 'Exception', - 'BaseException', 'object'] -else: - RUNTIME_ERROR_CLASSES = ['RuntimeError', 'StandardError', 'Exception', - 'BaseException', 'object'] +RUNTIME_ERROR_CLASSES = ['RuntimeError', 'Exception', + 'BaseException', 'object'] def dummy_decorator(f): - @six.wraps(f) + @functools.wraps(f) def wrapper(*args, **kwargs): return f(*args, **kwargs) @@ -88,7 +83,7 @@ class ClassWithInit(object): - def __init__(self, k, l): + def __init__(self, k, lll): pass @@ -192,13 +187,8 @@ def test_static_method(self): name = reflection.get_callable_name(Class.static_method) - if six.PY3: - self.assertEqual('.'.join((__name__, 'Class', 'static_method')), - name) - else: - # NOTE(imelnikov): static method are just functions, class name - # is not recorded anywhere in them. - self.assertEqual('.'.join((__name__, 'static_method')), name) + self.assertEqual('.'.join((__name__, 'Class', 'static_method')), + name) def test_class_method(self): name = reflection.get_callable_name(Class.class_method) @@ -218,9 +208,6 @@ '__call__')), name) -# These extended/special case tests only work on python 3, due to python 2 -# being broken/incorrect with regard to these special cases... -@testtools.skipIf(not six.PY3, 'python 3.x is not currently available') class GetCallableNameTestExtended(test_base.BaseTestCase): # Tests items in http://legacy.python.org/dev/peps/pep-3155/ @@ -287,7 +274,7 @@ def test_class_constructor(self): result = reflection.get_callable_args(ClassWithInit) - self.assertEqual(['k', 'l'], result) + self.assertEqual(['k', 'lll'], result) def test_class_with_call(self): result = reflection.get_callable_args(CallableClass()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/tests/test_secretutils.py new/oslo.utils-4.8.0/oslo_utils/tests/test_secretutils.py --- old/oslo.utils-4.6.0/oslo_utils/tests/test_secretutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/tests/test_secretutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -61,3 +61,50 @@ self.assertFalse(ctc(self.converter(u'abcd1234'), self.converter(u'1234abcd'))) self.assertFalse(ctc('abcd1234', '1234abcd')) + + _test_data = "Openstack forever".encode('utf-8') + _md5_digest = hashlib.md5(_test_data).digest() + + def test_md5_with_data(self): + digest = secretutils.md5(self._test_data).digest() + self.assertEqual(digest, self._md5_digest) + + digest = secretutils.md5(self._test_data, + usedforsecurity=True).digest() + self.assertEqual(digest, self._md5_digest) + + digest = secretutils.md5(self._test_data, + usedforsecurity=False).digest() + self.assertEqual(digest, self._md5_digest) + + def test_md5_without_data(self): + md5 = secretutils.md5() + md5.update(self._test_data) + digest = md5.digest() + self.assertEqual(digest, self._md5_digest) + + md5 = secretutils.md5(usedforsecurity=True) + md5.update(self._test_data) + digest = md5.digest() + self.assertEqual(digest, self._md5_digest) + + md5 = secretutils.md5(usedforsecurity=False) + md5.update(self._test_data) + digest = md5.digest() + self.assertEqual(digest, self._md5_digest) + + def test_string_data_raises_type_error(self): + self.assertRaises(TypeError, hashlib.md5, 'foo') + self.assertRaises(TypeError, secretutils.md5, 'foo') + self.assertRaises( + TypeError, secretutils.md5, 'foo', usedforsecurity=True) + self.assertRaises( + TypeError, secretutils.md5, 'foo', usedforsecurity=False) + + def test_none_data_raises_type_error(self): + self.assertRaises(TypeError, hashlib.md5, None) + self.assertRaises(TypeError, secretutils.md5, None) + self.assertRaises( + TypeError, secretutils.md5, None, usedforsecurity=True) + self.assertRaises( + TypeError, secretutils.md5, None, usedforsecurity=False) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/tests/test_strutils.py new/oslo.utils-4.8.0/oslo_utils/tests/test_strutils.py --- old/oslo.utils-4.6.0/oslo_utils/tests/test_strutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/tests/test_strutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -22,7 +22,6 @@ import ddt from oslotest import base as test_base -import six import testscenarios from oslo_utils import strutils @@ -33,12 +32,6 @@ class StrUtilsTest(test_base.BaseTestCase): - @mock.patch("six.text_type") - def test_bool_bool_from_string_no_text(self, mock_text): - self.assertTrue(strutils.bool_from_string(True)) - self.assertFalse(strutils.bool_from_string(False)) - self.assertEqual(0, mock_text.call_count) - def test_bool_bool_from_string(self): self.assertTrue(strutils.bool_from_string(True)) self.assertFalse(strutils.bool_from_string(False)) @@ -85,7 +78,7 @@ self._test_bool_from_string(lambda s: s) def test_unicode_bool_from_string(self): - self._test_bool_from_string(six.text_type) + self._test_bool_from_string(str) self.assertFalse(strutils.bool_from_string(u'??????', strict=False)) exc = self.assertRaises(ValueError, strutils.bool_from_string, @@ -93,7 +86,7 @@ expected_msg = (u"Unrecognized value '??????', acceptable values are:" u" '0', '1', 'f', 'false', 'n', 'no', 'off', 'on'," u" 't', 'true', 'y', 'yes'") - self.assertEqual(expected_msg, six.text_type(exc)) + self.assertEqual(expected_msg, str(exc)) def test_other_bool_from_string(self): self.assertFalse(strutils.bool_from_string(None)) @@ -170,16 +163,17 @@ def test_slugify(self): to_slug = strutils.to_slug self.assertRaises(TypeError, to_slug, True) - self.assertEqual(six.u("hello"), to_slug("hello")) - self.assertEqual(six.u("two-words"), to_slug("Two Words")) - self.assertEqual(six.u("ma-any-spa-ce-es"), + self.assertEqual("hello", to_slug("hello")) + self.assertEqual("two-words", to_slug("Two Words")) + self.assertEqual("ma-any-spa-ce-es", to_slug("Ma-any\t spa--ce- es")) - self.assertEqual(six.u("excamation"), to_slug("exc!amation!")) - self.assertEqual(six.u("ampserand"), to_slug("&ser$and")) - self.assertEqual(six.u("ju5tnum8er"), to_slug("ju5tnum8er")) - self.assertEqual(six.u("strip-"), to_slug(" strip - ")) - self.assertEqual(six.u("perche"), to_slug(six.b("perch\xc3\xa9"))) - self.assertEqual(six.u("strange"), + self.assertEqual("excamation", to_slug("exc!amation!")) + self.assertEqual("ampserand", to_slug("&ser$and")) + self.assertEqual("ju5tnum8er", to_slug("ju5tnum8er")) + self.assertEqual("strip-", to_slug(" strip - ")) + self.assertEqual("perche", + to_slug("perch\xc3\xa9".encode("latin-1"))) + self.assertEqual("strange", to_slug("\x80strange", errors="ignore")) @@ -619,12 +613,12 @@ self.assertEqual(expected, strutils.mask_password(payload)) payload = """{'adminPass':'TL0EfN33'}""" - payload = six.text_type(payload) + payload = str(payload) expected = """{'adminPass':'***'}""" self.assertEqual(expected, strutils.mask_password(payload)) payload = """{'token':'mytoken'}""" - payload = six.text_type(payload) + payload = str(payload) expected = """{'token':'***'}""" self.assertEqual(expected, strutils.mask_password(payload)) @@ -950,7 +944,7 @@ "min_value": 300, "max_value": 300}, {"value": 55, "name": "doing 55 in a 54", "max_value": 54}, - {"value": six.unichr(129), "name": "UnicodeError", + {"value": chr(129), "name": "UnicodeError", "max_value": 1000}) def test_invalid_inputs(self, value, name, **kwargs): self.assertRaises(ValueError, strutils.validate_integer, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/tests/tests_encodeutils.py new/oslo.utils-4.8.0/oslo_utils/tests/tests_encodeutils.py --- old/oslo.utils-4.6.0/oslo_utils/tests/tests_encodeutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/tests/tests_encodeutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -19,8 +19,6 @@ from oslo_i18n import fixture as oslo_i18n_fixture from oslotest import base as test_base -import six -import testtools from oslo_utils import encodeutils @@ -30,25 +28,23 @@ def test_safe_decode(self): safe_decode = encodeutils.safe_decode self.assertRaises(TypeError, safe_decode, True) - self.assertEqual(six.u('ni\xf1o'), safe_decode(six.b("ni\xc3\xb1o"), - incoming="utf-8")) - if six.PY2: - # In Python 3, bytes.decode() doesn't support anymore - # bytes => bytes encodings like base64 - self.assertEqual(six.u("test"), safe_decode("dGVzdA==", - incoming='base64')) + self.assertEqual('ni\xf1o', + safe_decode("ni\xc3\xb1o".encode("latin-1"), + incoming="utf-8")) + + self.assertEqual("strange", + safe_decode('\x80strange'.encode("latin-1"), + errors='ignore')) - self.assertEqual(six.u("strange"), safe_decode(six.b('\x80strange'), - errors='ignore')) - - self.assertEqual(six.u('\xc0'), safe_decode(six.b('\xc0'), + self.assertEqual('\xc0', safe_decode('\xc0'.encode("latin-1"), incoming='iso-8859-1')) # Forcing incoming to ascii so it falls back to utf-8 - self.assertEqual(six.u('ni\xf1o'), safe_decode(six.b('ni\xc3\xb1o'), - incoming='ascii')) + self.assertEqual('ni\xf1o', + safe_decode('ni\xc3\xb1o'.encode("latin-1"), + incoming='ascii')) - self.assertEqual(six.u('foo'), safe_decode(b'foo')) + self.assertEqual('foo', safe_decode(b'foo')) def test_safe_encode_none_instead_of_text(self): self.assertRaises(TypeError, encodeutils.safe_encode, None) @@ -68,28 +64,18 @@ def test_safe_encode_tuple_instead_of_text(self): self.assertRaises(TypeError, encodeutils.safe_encode, ('foo', 'bar', )) - def test_safe_encode_py2(self): - if six.PY2: - # In Python 3, str.encode() doesn't support anymore - # text => text encodings like base64 - self.assertEqual( - six.b("dGVzdA==\n"), - encodeutils.safe_encode("test", encoding='base64'), - ) - else: - self.skipTest("Requires py2.x") - def test_safe_encode_force_incoming_utf8_to_ascii(self): # Forcing incoming to ascii so it falls back to utf-8 self.assertEqual( - six.b('ni\xc3\xb1o'), - encodeutils.safe_encode(six.b('ni\xc3\xb1o'), incoming='ascii'), + 'ni\xc3\xb1o'.encode("latin-1"), + encodeutils.safe_encode('ni\xc3\xb1o'.encode("latin-1"), + incoming='ascii'), ) def test_safe_encode_same_encoding_different_cases(self): with mock.patch.object(encodeutils, 'safe_decode', mock.Mock()): utf8 = encodeutils.safe_encode( - six.u('foo\xf1bar'), encoding='utf-8') + 'foo\xf1bar', encoding='utf-8') self.assertEqual( encodeutils.safe_encode(utf8, 'UTF-8', 'utf-8'), encodeutils.safe_encode(utf8, 'utf-8', 'UTF-8'), @@ -101,11 +87,11 @@ encodeutils.safe_decode.assert_has_calls([]) def test_safe_encode_different_encodings(self): - text = six.u('foo\xc3\xb1bar') + text = 'foo\xc3\xb1bar' result = encodeutils.safe_encode( text=text, incoming='utf-8', encoding='iso-8859-1') self.assertNotEqual(text, result) - self.assertNotEqual(six.b("foo\xf1bar"), result) + self.assertNotEqual("foo\xf1bar".encode("latin-1"), result) def test_to_utf8(self): self.assertEqual(encodeutils.to_utf8(b'a\xe9\xff'), # bytes @@ -115,7 +101,7 @@ self.assertRaises(TypeError, encodeutils.to_utf8, 123) # invalid # oslo.i18n Message objects should also be accepted for convenience. - # It works because Message is a subclass of six.text_type. Use the + # It works because Message is a subclass of str. Use the # lazy translation to get a Message instance of oslo_i18n. msg = oslo_i18n_fixture.Translation().lazy("test") self.assertEqual(encodeutils.to_utf8(msg), @@ -177,79 +163,6 @@ self.assertEqual(encodeutils.exception_to_unicode(exc), u'\u0420\u0443\u0441\u0441\u043a\u0438\u0439') - @testtools.skipIf(six.PY3, 'test specific to Python 2') - def test_unicode_exception(self): - # Exception with a __unicode__() method, but no __str__() - class UnicodeException(Exception): - def __init__(self, value): - Exception.__init__(self) - self.value = value - - def __unicode__(self): - return self.value - - # __unicode__() returns unicode - exc = UnicodeException(u'unicode \xe9\u20ac') - self.assertEqual(encodeutils.exception_to_unicode(exc), - u'unicode \xe9\u20ac') - - # __unicode__() returns bytes (does this case really happen in the - # wild?) - exc = UnicodeException(b'utf-8 \xc3\xa9\xe2\x82\xac') - self.assertEqual(encodeutils.exception_to_unicode(exc), - u'utf-8 \xe9\u20ac') - - @testtools.skipIf(six.PY3, 'test specific to Python 2') - def test_unicode_or_str_exception(self): - # Exception with __str__() and __unicode__() methods - class UnicodeOrStrException(Exception): - def __init__(self, unicode_value, str_value): - Exception.__init__(self) - self.unicode_value = unicode_value - self.str_value = str_value - - def __unicode__(self): - return self.unicode_value - - def __str__(self): - return self.str_value - - # __unicode__() returns unicode - exc = UnicodeOrStrException(u'unicode \xe9\u20ac', b'str') - self.assertEqual(encodeutils.exception_to_unicode(exc), - u'unicode \xe9\u20ac') - - # __unicode__() returns bytes (does this case really happen in the - # wild?) - exc = UnicodeOrStrException(b'utf-8 \xc3\xa9\xe2\x82\xac', b'str') - self.assertEqual(encodeutils.exception_to_unicode(exc), - u'utf-8 \xe9\u20ac') - - @testtools.skipIf(six.PY3, 'test specific to Python 2') - def test_unicode_only_exception(self): - # Exception with a __unicode__() method and a __str__() which - # raises an exception (similar to the Message class of oslo_i18n) - class UnicodeOnlyException(Exception): - def __init__(self, value): - Exception.__init__(self) - self.value = value - - def __unicode__(self): - return self.value - - def __str__(self): - raise UnicodeError("use unicode()") - - # __unicode__() returns unicode - exc = UnicodeOnlyException(u'unicode \xe9\u20ac') - self.assertEqual(encodeutils.exception_to_unicode(exc), - u'unicode \xe9\u20ac') - - # __unicode__() returns bytes - exc = UnicodeOnlyException(b'utf-8 \xc3\xa9\xe2\x82\xac') - self.assertEqual(encodeutils.exception_to_unicode(exc), - u'utf-8 \xe9\u20ac') - def test_oslo_i18n_message(self): # use the lazy translation to get a Message instance of oslo_i18n exc = oslo_i18n_fixture.Translation().lazy("test") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/timeutils.py new/oslo.utils-4.8.0/oslo_utils/timeutils.py --- old/oslo.utils-4.6.0/oslo_utils/timeutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/timeutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -19,13 +19,13 @@ import calendar import datetime +import functools import logging import time from debtcollector import removals import iso8601 import pytz -import six from oslo_utils import reflection @@ -66,9 +66,9 @@ try: return iso8601.parse_date(timestr) except iso8601.ParseError as e: - raise ValueError(six.text_type(e)) + raise ValueError(str(e)) except TypeError as e: - raise ValueError(six.text_type(e)) + raise ValueError(str(e)) @removals.remove( @@ -114,7 +114,7 @@ Accept datetime string with timezone information. Fix comparison with timezone aware datetime. """ - if isinstance(before, six.string_types): + if isinstance(before, str): before = parse_isotime(before) before = normalize_time(before) @@ -129,7 +129,7 @@ Accept datetime string with timezone information. Fix comparison with timezone aware datetime. """ - if isinstance(after, six.string_types): + if isinstance(after, str): after = parse_isotime(after) after = normalize_time(after) @@ -377,7 +377,7 @@ if not enabled: return func - @six.wraps(func) + @functools.wraps(func) def wrapper(*args, **kwargs): with StopWatch() as w: result = func(*args, **kwargs) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/oslo_utils/versionutils.py new/oslo.utils-4.8.0/oslo_utils/versionutils.py --- old/oslo.utils-4.6.0/oslo_utils/versionutils.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/oslo_utils/versionutils.py 2021-02-16 10:01:47.000000000 +0100 @@ -19,8 +19,9 @@ .. versionadded:: 1.6 """ +import functools + import packaging.version -import six from oslo_utils._i18n import _ @@ -57,13 +58,13 @@ .. versionadded:: 2.0 """ try: - if isinstance(version, six.string_types): + if isinstance(version, str): version = convert_version_to_tuple(version) if isinstance(version, tuple): - return six.moves.reduce(lambda x, y: (x * 1000) + y, version) + return functools.reduce(lambda x, y: (x * 1000) + y, version) except Exception as ex: msg = _("Version %s is invalid.") % version - six.raise_from(ValueError(msg), ex) + raise ValueError(msg) from ex def convert_version_to_str(version_int): @@ -75,7 +76,7 @@ factor = 1000 while version_int != 0: version_number = version_int - (version_int // factor * factor) - version_numbers.insert(0, six.text_type(version_number)) + version_numbers.insert(0, str(version_number)) version_int = version_int // factor return '.'.join(map(str, version_numbers)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/releasenotes/notes/add-md5-wrapper-7bf81c2464a7a224.yaml new/oslo.utils-4.8.0/releasenotes/notes/add-md5-wrapper-7bf81c2464a7a224.yaml --- old/oslo.utils-4.6.0/releasenotes/notes/add-md5-wrapper-7bf81c2464a7a224.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/oslo.utils-4.8.0/releasenotes/notes/add-md5-wrapper-7bf81c2464a7a224.yaml 2021-02-16 10:01:47.000000000 +0100 @@ -0,0 +1,16 @@ +--- +features: + - | + A wrapper for hashlib.md5() has been added to allow OpenStack to run on + systems where FIPS is enabled. Under FIPS, md5 is disabled and calls to + hashlib.md5() will fail. In most cases in OpenStack, though, md5 is not + used within a security context. + + In https://bugs.python.org/issue9216, a proposal has been made to allow + the addition of a keyword parameter usedforsecurity, which can be used to + designate non-security context uses. In this case, md5() operations would + be permitted. This feature is expected to be delivered in python 3.9. + + Downstream python already supports this option, though. This wrapper + simply allows for this option to be supported where the underlying python + version supports it. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/releasenotes/notes/allow-to-convert-ipv4-address-from-text-to-binary-8c46ad2d9989e8c5.yaml new/oslo.utils-4.8.0/releasenotes/notes/allow-to-convert-ipv4-address-from-text-to-binary-8c46ad2d9989e8c5.yaml --- old/oslo.utils-4.6.0/releasenotes/notes/allow-to-convert-ipv4-address-from-text-to-binary-8c46ad2d9989e8c5.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/oslo.utils-4.8.0/releasenotes/notes/allow-to-convert-ipv4-address-from-text-to-binary-8c46ad2d9989e8c5.yaml 2021-02-16 10:01:47.000000000 +0100 @@ -0,0 +1,6 @@ +--- +features: + - | + Add a ``strict`` flag to ``netutils.is_valid_ipv4`` to allowing users to + restrict validation to IP addresses in presentation format (``a.b.c.d``) + as opposed to address format (``a.b.c.d``, ``a.b.c``, ``a.b``, ``a``). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/releasenotes/source/conf.py new/oslo.utils-4.8.0/releasenotes/source/conf.py --- old/oslo.utils-4.6.0/releasenotes/source/conf.py 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/releasenotes/source/conf.py 2021-02-16 10:01:47.000000000 +0100 @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2020 Red Hat, Inc. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/releasenotes/source/index.rst new/oslo.utils-4.8.0/releasenotes/source/index.rst --- old/oslo.utils-4.6.0/releasenotes/source/index.rst 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/releasenotes/source/index.rst 2021-02-16 10:01:47.000000000 +0100 @@ -6,6 +6,7 @@ :maxdepth: 1 unreleased + victoria ussuri train stein diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/releasenotes/source/victoria.rst new/oslo.utils-4.8.0/releasenotes/source/victoria.rst --- old/oslo.utils-4.6.0/releasenotes/source/victoria.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/oslo.utils-4.8.0/releasenotes/source/victoria.rst 2021-02-16 10:01:47.000000000 +0100 @@ -0,0 +1,6 @@ +============================= +Victoria Series Release Notes +============================= + +.. release-notes:: + :branch: stable/victoria diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/requirements.txt new/oslo.utils-4.8.0/requirements.txt --- old/oslo.utils-4.6.0/requirements.txt 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/requirements.txt 2021-02-16 10:01:47.000000000 +0100 @@ -8,7 +8,6 @@ # that is a likely indicator that the feature belongs somewhere else. pbr!=2.1.0,>=2.0.0 # Apache-2.0 -six>=1.10.0 # MIT iso8601>=0.1.11 # MIT oslo.i18n>=3.15.3 # Apache-2.0 pytz>=2013.6 # MIT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/test-requirements.txt new/oslo.utils-4.8.0/test-requirements.txt --- old/oslo.utils-4.6.0/test-requirements.txt 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/test-requirements.txt 2021-02-16 10:01:47.000000000 +0100 @@ -22,3 +22,5 @@ # Bandit security code scanner bandit>=1.6.0,<1.7.0 # Apache-2.0 + +pre-commit>=2.6.0 # MIT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.utils-4.6.0/tox.ini new/oslo.utils-4.8.0/tox.ini --- old/oslo.utils-4.6.0/tox.ini 2020-09-11 21:22:56.000000000 +0200 +++ new/oslo.utils-4.8.0/tox.ini 2021-02-16 10:01:47.000000000 +0100 @@ -1,19 +1,19 @@ [tox] minversion = 3.1 -envlist = py37,pep8 +envlist = py3,pep8 ignore_basepython_conflict = true [testenv] basepython = python3 deps = - -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt commands = stestr run --slowest {posargs} [testenv:pep8] commands = - flake8 + pre-commit run -a # Run security linter bandit -r oslo_utils -x tests -n5 @@ -23,7 +23,7 @@ [testenv:docs] whitelist_externals = rm deps = - -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/doc/requirements.txt commands = rm -fr doc/build