From 49343a83b140e12deb346a6bdfa2a4d9b1311df1 Mon Sep 17 00:00:00 2001 From: Miro HronĨok Date: Jun 13 2018 13:07:49 +0000 Subject: Prepare for Python 3.7 --- diff --git a/a4996b4ce7d2a1b651ae984ee3448b8913577c5f.patch b/a4996b4ce7d2a1b651ae984ee3448b8913577c5f.patch new file mode 100644 index 0000000..bdeb06b --- /dev/null +++ b/a4996b4ce7d2a1b651ae984ee3448b8913577c5f.patch @@ -0,0 +1,31 @@ +From a4996b4ce7d2a1b651ae984ee3448b8913577c5f Mon Sep 17 00:00:00 2001 +From: Claudiu Popa +Date: Mon, 4 Jun 2018 07:49:27 -0700 +Subject: [PATCH] Check if the ModuleSpec origin is None to figure out if it is + a namespace package + +ModuleSpec.origin was changed in https://github.com/python/cpython/pull/5481 +to be None for namespace packages. +--- + astroid/interpreter/_import/spec.py | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/astroid/interpreter/_import/spec.py b/astroid/interpreter/_import/spec.py +index b328b74f..524a8b1a 100644 +--- a/astroid/interpreter/_import/spec.py ++++ b/astroid/interpreter/_import/spec.py +@@ -160,8 +160,12 @@ class PathSpecFinder(Finder): + def find_module(self, modname, module_parts, processed, submodule_path): + spec = importlib.machinery.PathFinder.find_spec(modname, path=submodule_path) + if spec: +- location = spec.origin if spec.origin != 'namespace' else None +- module_type = ModuleType.PY_NAMESPACE if spec.origin == 'namespace' else None ++ # origin can be either a string on older Python versions ++ # or None in case it is a namespace package: ++ # https://github.com/python/cpython/pull/5481 ++ is_namespace_pkg = spec.origin in ('namespace', None) ++ location = spec.origin if not is_namespace_pkg else None ++ module_type = ModuleType.PY_NAMESPACE if is_namespace_pkg else None + spec = ModuleSpec(name=spec.name, location=location, + origin=spec.origin, module_type=module_type, + submodule_search_locations=list(spec.submodule_search_locations diff --git a/be874a94b81f2b9404722937f1ea0e105c3c034a.patch b/be874a94b81f2b9404722937f1ea0e105c3c034a.patch new file mode 100644 index 0000000..f11b323 --- /dev/null +++ b/be874a94b81f2b9404722937f1ea0e105c3c034a.patch @@ -0,0 +1,22 @@ +From be874a94b81f2b9404722937f1ea0e105c3c034a Mon Sep 17 00:00:00 2001 +From: Claudiu Popa +Date: Mon, 4 Jun 2018 07:09:41 -0700 +Subject: [PATCH] Adapt the ABCMeta test to take in account _py_abc + +--- + astroid/tests/unittest_scoped_nodes.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/astroid/tests/unittest_scoped_nodes.py b/astroid/tests/unittest_scoped_nodes.py +index 36c4155b..91a74942 100644 +--- a/astroid/tests/unittest_scoped_nodes.py ++++ b/astroid/tests/unittest_scoped_nodes.py +@@ -1187,7 +1187,7 @@ class WithMeta(object): + inferred = next(klass.infer()) + metaclass = inferred.metaclass() + self.assertIsInstance(metaclass, scoped_nodes.ClassDef) +- self.assertEqual(metaclass.qname(), 'abc.ABCMeta') ++ self.assertIn(metaclass.qname(), ('abc.ABCMeta', '_py_abc.ABCMeta')) + + def test_using_invalid_six_add_metaclass_call(self): + klass = builder.extract_node(''' diff --git a/python-astroid.spec b/python-astroid.spec index 50e2eae..e7b2d59 100644 --- a/python-astroid.spec +++ b/python-astroid.spec @@ -12,9 +12,12 @@ License: GPLv2+ URL: https://github.com/%{github_owner}/%{github_name} Source0: https://github.com/%{github_owner}/%{github_name}/archive/%{github_tag}/%{github_name}-%{pypi_ver}.tar.gz +Patch0: https://github.com/PyCQA/astroid/commit/be874a94b81f2b9404722937f1ea0e105c3c034a.patch +Patch1: https://github.com/PyCQA/astroid/commit/a4996b4ce7d2a1b651ae984ee3448b8913577c5f.patch + + # Requirements for tests (BuildRequires) and run (Requires) -%global t_requires python3-lazy-object-proxy python3-six python3-typed_ast python3-wrapt -# TODO remove python3-typed_ast once we update to Python 3.7 +%global t_requires python3-lazy-object-proxy python3-six python3-wrapt BuildArch: noarch