From ba04e230bd2ae722e0311d1272f696f25a1915eb Mon Sep 17 00:00:00 2001 From: Naoto Mizuno Date: Sun, 20 Sep 2020 19:47:22 +0900 Subject: [PATCH] Support Python 3.7 --- .github/workflows/python-package.yml | 2 +- README.md | 2 +- README_ja.md | 2 +- atcoder/__main__.py | 12 ++++++++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 9e37371..9a0834a 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8] + python-version: [3.7, 3.8] steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index 5d543da..d39e2fd 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ python -m atcoder [your-source-code] -o [single-combined-code] ### For all users -+ Python 3.8.2 ++ Python 3.7.0+, 3.8.0+ + pip ### For developer diff --git a/README_ja.md b/README_ja.md index e8e795b..96b9828 100644 --- a/README_ja.md +++ b/README_ja.md @@ -32,7 +32,7 @@ python -m atcoder [your-source-code] -o [single-combined-code] ### 利用者、開発者向け情報 -+ Python 3.8.2 ++ Python 3.7.0+, 3.8.0+ + pip ### 開発者向け情報 diff --git a/atcoder/__main__.py b/atcoder/__main__.py index 9040434..194c1e8 100644 --- a/atcoder/__main__.py +++ b/atcoder/__main__.py @@ -33,10 +33,18 @@ def iter_child_nodes( if isinstance(node, ast.Import): for name in node.names: if re.match(r'^atcoder\.?', name.name): - import_info = ImportInfo(node.lineno, node.end_lineno) + if hasattr(node, 'end_lineno'): + end_lineno = node.end_lineno + else: + end_lineno = node.lineno + import_info = ImportInfo(node.lineno, end_lineno) elif isinstance(node, ast.ImportFrom): if re.match(r'^atcoder\.?', node.module): - import_info = ImportInfo(node.lineno, node.end_lineno, node.module) + if hasattr(node, 'end_lineno'): + end_lineno = node.end_lineno + else: + end_lineno = node.lineno + import_info = ImportInfo(node.lineno, end_lineno, node.module) for child in ast.iter_child_nodes(node): result += iter_child_nodes(child, import_info)