Hello community, here is the log from the commit of package python-astroid for openSUSE:Factory checked in at 2019-03-29 20:37:03 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-astroid (Old) and /work/SRC/openSUSE:Factory/.python-astroid.new.25356 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-astroid" Fri Mar 29 20:37:03 2019 rev:19 rq:687619 version:2.2.5 Changes: -------- --- /work/SRC/openSUSE:Factory/python-astroid/python-astroid.changes 2019-03-08 11:01:23.744540859 +0100 +++ /work/SRC/openSUSE:Factory/.python-astroid.new.25356/python-astroid.changes 2019-03-29 20:37:04.798627118 +0100 @@ -1,0 +2,6 @@ +Mon Mar 11 09:46:52 UTC 2019 - Tomáš Chvátal <[email protected]> + +- Update to 2.2.5: + * The last except handler wins when inferring variables bound in an except handler. + +------------------------------------------------------------------- @@ -4 +10 @@ -- Update to 2.2.1: +- Update to 2.2.4: Old: ---- astroid-2.2.4.tar.gz New: ---- astroid-2.2.5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-astroid.spec ++++++ --- /var/tmp/diff_new_pack.qakI7X/_old 2019-03-29 20:37:05.334627416 +0100 +++ /var/tmp/diff_new_pack.qakI7X/_new 2019-03-29 20:37:05.342627420 +0100 @@ -19,7 +19,7 @@ %define skip_python2 1 %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-astroid -Version: 2.2.4 +Version: 2.2.5 Release: 0 Summary: Representation of Python source as an AST for pylint License: LGPL-2.1-or-later ++++++ astroid-2.2.4.tar.gz -> astroid-2.2.5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.2.4/ChangeLog new/astroid-2.2.5/ChangeLog --- old/astroid-2.2.4/ChangeLog 2019-03-05 10:54:36.000000000 +0100 +++ new/astroid-2.2.5/ChangeLog 2019-03-08 17:57:47.000000000 +0100 @@ -2,6 +2,14 @@ astroid's ChangeLog =================== +What's New in astroid 2.2.5? +============================ +Release Date: 2019-03-08 + +* The last except handler wins when inferring variables bound in an except handler. + + Close PyCQA/pylint#2777, PyCQA/pylint#2802 + What's New in astroid 2.2.4? ============================ Release Date: 2019-03-05 @@ -42,6 +50,10 @@ Close PyCQA/pylint#2776 +* The last except handler wins when inferring variables bound in an except handler. + + Close PyCQA/pylint#2777 + What's New in astroid 2.2.0? ============================ Release Date: 2019-02-27 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.2.4/PKG-INFO new/astroid-2.2.5/PKG-INFO --- old/astroid-2.2.4/PKG-INFO 2019-03-05 10:56:04.000000000 +0100 +++ new/astroid-2.2.5/PKG-INFO 2019-03-08 17:59:17.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: astroid -Version: 2.2.4 +Version: 2.2.5 Summary: An abstract syntax tree for Python with inference support. Home-page: https://github.com/PyCQA/astroid Author: Python Code Quality Authority diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.2.4/astroid/__pkginfo__.py new/astroid-2.2.5/astroid/__pkginfo__.py --- old/astroid-2.2.4/astroid/__pkginfo__.py 2019-03-05 10:54:36.000000000 +0100 +++ new/astroid-2.2.5/astroid/__pkginfo__.py 2019-03-08 17:57:47.000000000 +0100 @@ -21,7 +21,7 @@ modname = "astroid" -version = "2.2.4" +version = "2.2.5" numversion = tuple(int(elem) for elem in version.split(".") if elem.isdigit()) extras_require = {} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.2.4/astroid/node_classes.py new/astroid-2.2.5/astroid/node_classes.py --- old/astroid-2.2.4/astroid/node_classes.py 2019-03-05 10:54:36.000000000 +0100 +++ new/astroid-2.2.5/astroid/node_classes.py 2019-03-08 17:57:47.000000000 +0100 @@ -1096,6 +1096,18 @@ context = contextmod.InferenceContext() return bases._infer_stmts(stmts, context, frame) + def _get_filtered_node_statements(self, nodes): + statements = [(node, node.statement()) for node in nodes] + # Next we check if we have ExceptHandlers that are parent + # of the underlying variable, in which case the last one survives + if len(statements) > 1 and all( + isinstance(stmt, ExceptHandler) for _, stmt in statements + ): + statements = [ + (node, stmt) for node, stmt in statements if stmt.parent_of(self) + ] + return statements + def _filter_stmts(self, stmts, frame, offset): """Filter the given list of statements to remove ignorable statements. @@ -1149,10 +1161,12 @@ else: # disabling lineno filtering mylineno = 0 + _stmts = [] _stmt_parents = [] - for node in stmts: - stmt = node.statement() + statements = self._get_filtered_node_statements(stmts) + + for node, stmt in statements: # line filtering is on and we have reached our location, break if stmt.fromlineno > mylineno > 0: break diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.2.4/astroid/tests/unittest_inference.py new/astroid-2.2.5/astroid/tests/unittest_inference.py --- old/astroid-2.2.4/astroid/tests/unittest_inference.py 2019-03-05 10:54:36.000000000 +0100 +++ new/astroid-2.2.5/astroid/tests/unittest_inference.py 2019-03-08 17:57:47.000000000 +0100 @@ -5090,5 +5090,64 @@ assert isinstance(inferred, Slice) +def test_exception_lookup_last_except_handler_wins(): + node = extract_node( + """ + try: + 1/0 + except ValueError as exc: + pass + try: + 1/0 + except OSError as exc: + exc #@ + """ + ) + inferred = node.inferred() + assert len(inferred) == 1 + inferred_exc = inferred[0] + assert isinstance(inferred_exc, Instance) + assert inferred_exc.name == "OSError" + + # Check that two except handlers on the same TryExcept works the same as separate + # TryExcepts + node = extract_node( + """ + try: + 1/0 + except ZeroDivisionError as exc: + pass + except ValueError as exc: + exc #@ + """ + ) + inferred = node.inferred() + assert len(inferred) == 1 + inferred_exc = inferred[0] + assert isinstance(inferred_exc, Instance) + assert inferred_exc.name == "ValueError" + + +def test_exception_lookup_name_bound_in_except_handler(): + node = extract_node( + """ + try: + 1/0 + except ValueError: + name = 1 + try: + 1/0 + except OSError: + name = 2 + name #@ + """ + ) + inferred = node.inferred() + assert len(inferred) == 1 + inferred_exc = inferred[0] + assert isinstance(inferred_exc, nodes.Const) + assert inferred_exc.value == 2 + + if __name__ == "__main__": unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.2.4/astroid.egg-info/PKG-INFO new/astroid-2.2.5/astroid.egg-info/PKG-INFO --- old/astroid-2.2.4/astroid.egg-info/PKG-INFO 2019-03-05 10:56:04.000000000 +0100 +++ new/astroid-2.2.5/astroid.egg-info/PKG-INFO 2019-03-08 17:59:16.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: astroid -Version: 2.2.4 +Version: 2.2.5 Summary: An abstract syntax tree for Python with inference support. Home-page: https://github.com/PyCQA/astroid Author: Python Code Quality Authority
