[arch-commits] Commit in python-astor/repos/community-any (3 files)
Felix Yan
felixonmars at archlinux.org
Tue Feb 19 19:38:24 UTC 2019
Date: Tuesday, February 19, 2019 @ 19:38:23
Author: felixonmars
Revision: 434583
archrelease: copy trunk to community-any
Added:
python-astor/repos/community-any/PKGBUILD
(from rev 434582, python-astor/trunk/PKGBUILD)
python-astor/repos/community-any/string-newline.patch
(from rev 434582, python-astor/trunk/string-newline.patch)
Deleted:
python-astor/repos/community-any/PKGBUILD
----------------------+
PKGBUILD | 88 ++++++++++++++++++++-----------------------------
string-newline.patch | 56 +++++++++++++++++++++++++++++++
2 files changed, 92 insertions(+), 52 deletions(-)
Deleted: PKGBUILD
===================================================================
--- PKGBUILD 2019-02-19 19:38:05 UTC (rev 434582)
+++ PKGBUILD 2019-02-19 19:38:23 UTC (rev 434583)
@@ -1,52 +0,0 @@
-# $Id$
-# Maintainer: Felix Yan <felixonmars at archlinux.org>
-
-pkgbase=python-astor
-pkgname=('python-astor' 'python2-astor')
-pkgver=0.7.1
-pkgrel=1
-pkgdesc="Read/rewrite/write Python ASTs"
-arch=('any')
-license=('BSD')
-url="http://astor.rtfd.org/"
-makedepends=('python-setuptools' 'python2-setuptools')
-checkdepends=('python-nose' 'python2-nose' 'python2-unittest2')
-source=("$pkgbase-$pkgver.tar.gz::https://github.com/berkerpeksag/astor/archive/$pkgver.tar.gz")
-sha512sums=('02764e5751e4c4b0ffa83da262b87e0a6bf027461529a99d3ca01a415db0896754f2b3f278e8a28f9bce4972ee7a75eec4eec5ac47d1064e6d6656a007b38a64')
-
-prepare() {
- cp -a astor-$pkgver{,-py2}
-}
-
-build() {
- cd "$srcdir"/astor-$pkgver
- python setup.py build
-
- cd "$srcdir"/astor-$pkgver-py2
- python2 setup.py build
-}
-
-check() {
- # https://github.com/berkerpeksag/astor/issues/89
- cd "$srcdir"/astor-$pkgver
- nosetests3 || warning "Tests failed"
-
- cd "$srcdir"/astor-$pkgver-py2
- nosetests2
-}
-
-package_python-astor() {
- depends=('python')
-
- cd astor-$pkgver
- python setup.py install --root="$pkgdir" --optimize=1
- install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
-}
-
-package_python2-astor() {
- depends=('python2')
-
- cd astor-$pkgver-py2
- python2 setup.py install --root="$pkgdir" --optimize=1
- install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
-}
Copied: python-astor/repos/community-any/PKGBUILD (from rev 434582, python-astor/trunk/PKGBUILD)
===================================================================
--- PKGBUILD (rev 0)
+++ PKGBUILD 2019-02-19 19:38:23 UTC (rev 434583)
@@ -0,0 +1,36 @@
+# Maintainer: Felix Yan <felixonmars at archlinux.org>
+
+pkgname=python-astor
+pkgver=0.7.1
+pkgrel=2
+pkgdesc="Read/rewrite/write Python ASTs"
+arch=('any')
+license=('BSD')
+url="http://astor.rtfd.org/"
+depends=('python')
+makedepends=('python-setuptools')
+checkdepends=('python-nose')
+source=("$pkgname-$pkgver.tar.gz::https://github.com/berkerpeksag/astor/archive/$pkgver.tar.gz"
+ string-newline.patch)
+sha512sums=('02764e5751e4c4b0ffa83da262b87e0a6bf027461529a99d3ca01a415db0896754f2b3f278e8a28f9bce4972ee7a75eec4eec5ac47d1064e6d6656a007b38a64'
+ 'ad977606c1b0374dccece65a9743e875e250e86d923c987eee7babb09f1209a874a7b447f253e1666364da32e309579d261ac70cf32b3d909c9fe78501b19cb8')
+
+prepare() {
+ patch -d astor-$pkgver -p1 -i ../string-newline.patch
+}
+
+build() {
+ cd astor-$pkgver
+ python setup.py build
+}
+
+check() {
+ cd astor-$pkgver
+ nosetests3 || warning "https://github.com/berkerpeksag/astor/issues/124"
+}
+
+package() {
+ cd astor-$pkgver
+ python setup.py install --root="$pkgdir" --optimize=1
+ install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
+}
Copied: python-astor/repos/community-any/string-newline.patch (from rev 434582, python-astor/trunk/string-newline.patch)
===================================================================
--- string-newline.patch (rev 0)
+++ string-newline.patch 2019-02-19 19:38:23 UTC (rev 434583)
@@ -0,0 +1,56 @@
+commit 33f0e57bc84f0cd5cdf994127d81c99f2a23f659
+Author: Felix Yan <felixonmars at archlinux.org>
+Date: Wed Feb 20 01:56:35 2019 +0800
+
+ Fix string parsing with newline
+
+ When looping over a joined str, if a node is ast.Str and the value is
+ just a newline "\n", the write() function adds an additional indentation
+ after it, which fails to represent the original string. By calling
+ self.result.append() here directly the issue is resolved.
+
+ The added test could show the issue. With code_gen unmodifed, it fails
+ with the following error:
+
+ ```
+ AssertionError: "if 1:\n x = f'{host}\\n\\t{port}\\n '" != "if
+ 1:\n x = f'{host}\\n\\t{port}\\n'"
+ if 1:
+ - x = f'{host}\n\t{port}\n '?
+ ----
+ + x = f'{host}\n\t{port}\n'
+ ```
+
+ Which is exactly the problem.
+
+ This fixes parsing issues with many of Python 3.7's stdlib.
+
+diff --git a/astor/code_gen.py b/astor/code_gen.py
+index 157d2cc..453d108 100644
+--- a/astor/code_gen.py
++++ b/astor/code_gen.py
+@@ -566,7 +566,7 @@ class SourceGenerator(ExplicitNodeVisitor):
+ def recurse(node):
+ for value in node.values:
+ if isinstance(value, ast.Str):
+- self.write(value.s)
++ self.result.append(value.s)
+ elif isinstance(value, ast.FormattedValue):
+ with self.delimit('{}'):
+ self.visit(value.value)
+diff --git a/tests/test_code_gen.py b/tests/test_code_gen.py
+index 3a8be7b..0db4279 100644
+--- a/tests/test_code_gen.py
++++ b/tests/test_code_gen.py
+@@ -516,6 +516,11 @@ class CodegenTestCase(unittest.TestCase, Comparisons):
+ x = f"""{host}\n\t{port}\n"""
+ '''
+ self.assertSrcRoundtripsGtVer(source, (3, 6))
++ source = '''
++ if 1:
++ x = f'{host}\\n\\t{port}\\n'
++ '''
++ self.assertSrcRoundtripsGtVer(source, (3, 6))
+
+ def test_docstring_function(self):
+ source = '''
More information about the arch-commits
mailing list