Updated bundled libraries (#70418)

Change:
- Update bundled six to 1.13 (last with py2.6 support)
- Make it pass lint
- Fix check to allow skipping over compat __init__.py files we authored
- Fix check to allow files that can't be updated for some reason

Test Plan:
- ansible-test sanity --docker
- CI

Signed-off-by: Rick Elrod <rick@elrod.me>
pull/70442/head
Rick Elrod 4 years ago committed by GitHub
parent c600f8df58
commit 1be78dbfc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,6 +19,8 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
# NOT_BUNDLED
''' '''
Compat selectors library. Python-3.5 has this builtin. The selectors2 Compat selectors library. Python-3.5 has this builtin. The selectors2
package exists on pypi to backport the functionality as far as python-2.6. package exists on pypi to backport the functionality as far as python-2.6.

@ -3,7 +3,7 @@
# upstream vendored file that we're not going to modify on our own # upstream vendored file that we're not going to modify on our own
# pylint: disable=undefined-variable # pylint: disable=undefined-variable
# Copyright (c) 2010-2018 Benjamin Peterson # Copyright (c) 2010-2019 Benjamin Peterson
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal # of this software and associated documentation files (the "Software"), to deal
@ -35,10 +35,11 @@ import types
# The following makes it easier for us to script updates of the bundled code. It is not part of # The following makes it easier for us to script updates of the bundled code. It is not part of
# upstream six # upstream six
_BUNDLED_METADATA = {"pypi_name": "six", "version": "1.12.0"} # CANT_UPDATE due to py2.6 drop: https://github.com/benjaminp/six/pull/314
_BUNDLED_METADATA = {"pypi_name": "six", "version": "1.13.0"}
__author__ = "Benjamin Peterson <benjamin@python.org>" __author__ = "Benjamin Peterson <benjamin@python.org>"
__version__ = "1.12.0" __version__ = "1.13.0"
# Useful for very coarse version differentiation. # Useful for very coarse version differentiation.
@ -265,8 +266,10 @@ _moved_attributes = [
MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"), MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
MovedModule("builtins", "__builtin__"), MovedModule("builtins", "__builtin__"),
MovedModule("configparser", "ConfigParser"), MovedModule("configparser", "ConfigParser"),
MovedModule("collections_abc", "collections", "collections.abc" if sys.version_info >= (3, 3) else "collections"),
MovedModule("copyreg", "copy_reg"), MovedModule("copyreg", "copy_reg"),
MovedModule("dbm_gnu", "gdbm", "dbm.gnu"), MovedModule("dbm_gnu", "gdbm", "dbm.gnu"),
MovedModule("dbm_ndbm", "dbm", "dbm.ndbm"),
MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"), MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"),
MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
MovedModule("http_cookies", "Cookie", "http.cookies"), MovedModule("http_cookies", "Cookie", "http.cookies"),
@ -648,6 +651,7 @@ if PY3:
import io import io
StringIO = io.StringIO StringIO = io.StringIO
BytesIO = io.BytesIO BytesIO = io.BytesIO
del io
_assertCountEqual = "assertCountEqual" _assertCountEqual = "assertCountEqual"
if sys.version_info[1] <= 1: if sys.version_info[1] <= 1:
_assertRaisesRegex = "assertRaisesRegexp" _assertRaisesRegex = "assertRaisesRegexp"
@ -835,7 +839,15 @@ def with_metaclass(meta, *bases):
class metaclass(type): class metaclass(type):
def __new__(cls, name, this_bases, d): def __new__(cls, name, this_bases, d):
return meta(name, bases, d) if sys.version_info[:2] >= (3, 7):
# This version introduced PEP 560 that requires a bit
# of extra care (we mimic what is done by __build_class__).
resolved_bases = types.resolve_bases(bases)
if resolved_bases is not bases:
d['__orig_bases__'] = bases
else:
resolved_bases = bases
return meta(name, resolved_bases, d)
@classmethod @classmethod
def __prepare__(cls, name, this_bases): def __prepare__(cls, name, this_bases):

@ -51,9 +51,9 @@ def get_bundled_libs(paths):
for filename in fnmatch.filter(paths, 'lib/ansible/compat/*/__init__.py'): for filename in fnmatch.filter(paths, 'lib/ansible/compat/*/__init__.py'):
bundled_libs.add(filename) bundled_libs.add(filename)
bundled_libs.add('lib/ansible/module_utils/compat/selectors.py')
bundled_libs.add('lib/ansible/module_utils/distro/__init__.py') bundled_libs.add('lib/ansible/module_utils/distro/__init__.py')
bundled_libs.add('lib/ansible/module_utils/six/__init__.py') bundled_libs.add('lib/ansible/module_utils/six/__init__.py')
bundled_libs.add('lib/ansible/module_utils/compat/ipaddress.py')
# backports.ssl_match_hostname should be moved to its own file in the future # backports.ssl_match_hostname should be moved to its own file in the future
bundled_libs.add('lib/ansible/module_utils/urls.py') bundled_libs.add('lib/ansible/module_utils/urls.py')
@ -89,6 +89,15 @@ def get_bundled_metadata(filename):
""" """
with open(filename, 'r') as module: with open(filename, 'r') as module:
for line in module: for line in module:
if line.strip().startswith('# NOT_BUNDLED'):
return None
if line.strip().startswith('# CANT_UPDATE'):
print(
'{0} marked as CANT_UPDATE, so skipping. Manual '
'check for CVEs required.'.format(filename))
return None
if line.strip().startswith('_BUNDLED_METADATA'): if line.strip().startswith('_BUNDLED_METADATA'):
data = line[line.index('{'):].strip() data = line[line.index('{'):].strip()
break break
@ -146,6 +155,9 @@ def main():
' or moved and the bundled library test needs to be modified as' ' or moved and the bundled library test needs to be modified as'
' well?'.format(filename, e)) ' well?'.format(filename, e))
if metadata is None:
continue
pypi_fh = open_url('https://pypi.org/pypi/{0}/json'.format(metadata['pypi_name'])) pypi_fh = open_url('https://pypi.org/pypi/{0}/json'.format(metadata['pypi_name']))
pypi_data = json.loads(pypi_fh.read().decode('utf-8')) pypi_data = json.loads(pypi_fh.read().decode('utf-8'))

Loading…
Cancel
Save