forked from pool/python-asttokens
Accepting request 885980 from home:mcalabkova:branches:devel:languages:python
- Add patch py39.patch to fix build with Python 3.9 OBS-URL: https://build.opensuse.org/request/show/885980 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-asttokens?expand=0&rev=3
This commit is contained in:
parent
2b887a4314
commit
c32a7adc3c
50
py39.patch
Normal file
50
py39.patch
Normal file
@ -0,0 +1,50 @@
|
||||
From d8ff80ee7d2e64c5e1daf50cc38eb99663f1b1ac Mon Sep 17 00:00:00 2001
|
||||
From: Alex Hall <alex.mojaki@gmail.com>
|
||||
Date: Fri, 26 Feb 2021 15:49:29 +0200
|
||||
Subject: [PATCH] Make 3.9 support official, fix tests fo 3.9 involving starred
|
||||
expressions (#66)
|
||||
|
||||
* Handle starred expressions in tests
|
||||
* Make 3.9 support official
|
||||
* pypy2 instead of pypy2.7
|
||||
* pypy3 instead of pypy3.5
|
||||
---
|
||||
.travis.yml | 6 +++---
|
||||
asttokens/util.py | 5 +++++
|
||||
setup.cfg | 1 +
|
||||
tests/test_mark_tokens.py | 3 +++
|
||||
4 files changed, 12 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/asttokens/util.py b/asttokens/util.py
|
||||
index c29dd07..79ac430 100644
|
||||
--- a/asttokens/util.py
|
||||
+++ b/asttokens/util.py
|
||||
@@ -142,6 +142,11 @@ def is_joined_str(node):
|
||||
return node.__class__.__name__ == 'JoinedStr'
|
||||
|
||||
|
||||
+def is_starred(node):
|
||||
+ """Returns whether node is a starred expression node."""
|
||||
+ return node.__class__.__name__ == 'Starred'
|
||||
+
|
||||
+
|
||||
def is_slice(node):
|
||||
"""Returns whether node represents a slice, e.g. `1:2` in `x[1:2]`"""
|
||||
# Before 3.9, a tuple containing a slice is an ExtSlice,
|
||||
diff --git a/tests/test_mark_tokens.py b/tests/test_mark_tokens.py
|
||||
index a0f68b2..90cff20 100644
|
||||
--- a/tests/test_mark_tokens.py
|
||||
+++ b/tests/test_mark_tokens.py
|
||||
@@ -728,9 +728,12 @@ def parse_snippet(self, text, node):
|
||||
# For expressions and statements, we add a dummy statement '_' before it because if it's just a
|
||||
# string contained in an astroid.Const or astroid.Expr it will end up in the doc attribute and be
|
||||
# a pain to extract for comparison
|
||||
+ # For starred expressions, e.g. `*args`, we wrap it in a function call to make it parsable.
|
||||
indented = re.match(r'^[ \t]+\S', text)
|
||||
if indented:
|
||||
return self.module.parse('def dummy():\n' + text).body[0].body[0]
|
||||
+ if util.is_starred(node):
|
||||
+ return self.module.parse('f(' + text + ')').body[0].value.args[0]
|
||||
if util.is_expr(node):
|
||||
return self.module.parse('_\n(' + text + ')').body[1].value
|
||||
if util.is_module(node):
|
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Apr 16 12:42:11 UTC 2021 - Markéta Machová <mmachova@suse.com>
|
||||
|
||||
- Add patch py39.patch to fix build with Python 3.9
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Nov 12 14:38:22 UTC 2020 - malcolmlewis@opensuse.org
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#
|
||||
# spec file for package python-asttokens
|
||||
#
|
||||
# Copyright (c) 2021 SUSE LLC
|
||||
# Copyright (c) 2019-2020 Malcolm J Lewis <malcolmlewis@opensuse.org>
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
@ -12,27 +13,29 @@
|
||||
# license that conforms to the Open Source Definition (Version 1.9)
|
||||
# published by the Open Source Initiative.
|
||||
|
||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
Name: python-asttokens
|
||||
Version: 2.0.4
|
||||
Release: 0
|
||||
License: Apache-2.0
|
||||
Summary: Annotate AST trees with source code positions
|
||||
Url: https://github.com/gristlabs/asttokens
|
||||
License: Apache-2.0
|
||||
Group: Development/Languages/Python
|
||||
URL: https://github.com/gristlabs/asttokens
|
||||
Source: https://files.pythonhosted.org/packages/source/a/asttokens/asttokens-%{version}.tar.gz
|
||||
BuildRequires: python-rpm-macros
|
||||
Patch0: py39.patch
|
||||
BuildRequires: %{python_module astroid}
|
||||
BuildRequires: %{python_module devel}
|
||||
BuildRequires: %{python_module pytest}
|
||||
BuildRequires: %{python_module setuptools_scm}
|
||||
BuildRequires: %{python_module six}
|
||||
BuildRequires: %{python_module pytest}
|
||||
BuildRequires: %{python_module toml}
|
||||
BuildRequires: %{python_module wheel}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
## Manual Begin
|
||||
Requires: python-six
|
||||
## Manual End
|
||||
@ -44,6 +47,7 @@ Annotate AST trees with source code positions
|
||||
|
||||
%prep
|
||||
%setup -q -n asttokens-%{version}
|
||||
%autopatch -p1
|
||||
|
||||
%build
|
||||
export LC_ALL=en_US.utf8
|
||||
@ -55,7 +59,7 @@ export LC_ALL=en_US.utf8
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||
|
||||
%check
|
||||
%python_exec -m unittest discover -v
|
||||
%pyunittest -v
|
||||
|
||||
%files %{python_files}
|
||||
%doc README.rst
|
||||
|
Loading…
x
Reference in New Issue
Block a user