[arch-commits] Commit in python-astor/trunk (PKGBUILD string-newline.patch)
Date: Friday, May 31, 2019 @ 08:11:47 Author: felixonmars Revision: 475864 upgpkg: python-astor 0.8-1 Modified: python-astor/trunk/PKGBUILD Deleted: python-astor/trunk/string-newline.patch --+ PKGBUILD | 16 -- string-newline.patch | 56 - 2 files changed, 5 insertions(+), 67 deletions(-) Modified: PKGBUILD === --- PKGBUILD2019-05-31 07:35:39 UTC (rev 475863) +++ PKGBUILD2019-05-31 08:11:47 UTC (rev 475864) @@ -1,8 +1,8 @@ # Maintainer: Felix Yan pkgname=python-astor -pkgver=0.7.1 -pkgrel=2 +pkgver=0.8 +pkgrel=1 pkgdesc="Read/rewrite/write Python ASTs" arch=('any') license=('BSD') @@ -10,15 +10,9 @@ 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') +source=("$pkgname-$pkgver.tar.gz::https://github.com/berkerpeksag/astor/archive/$pkgver.tar.gz;) +sha512sums=('ca787234f9a9caae37633be289d6e980e7b44507d74306ad7a30f017442d6cf423748ef35465b7b5d12bdb84ce4594af801de39882f4c11c732dba4dc65ab667') -prepare() { - patch -d astor-$pkgver -p1 -i ../string-newline.patch -} - build() { cd astor-$pkgver python setup.py build @@ -26,7 +20,7 @@ check() { cd astor-$pkgver - nosetests3 || warning "https://github.com/berkerpeksag/astor/issues/124; + nosetests3 || warning "https://github.com/berkerpeksag/astor/issues/146; } package() { Deleted: string-newline.patch === --- string-newline.patch2019-05-31 07:35:39 UTC (rev 475863) +++ string-newline.patch2019-05-31 08:11:47 UTC (rev 475864) @@ -1,56 +0,0 @@ -commit 33f0e57bc84f0cd5cdf994127d81c99f2a23f659 -Author: Felix Yan -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:\nx = f'{host}\\n\\t{port}\\n'" != "if -1:\nx = 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 = '''
[arch-commits] Commit in python-astor/trunk (PKGBUILD string-newline.patch)
Date: Tuesday, February 19, 2019 @ 19:38:05 Author: felixonmars Revision: 434582 upgpkg: python-astor 0.7.1-2 remove python2 sibling Added: python-astor/trunk/string-newline.patch Modified: python-astor/trunk/PKGBUILD --+ PKGBUILD | 43 - string-newline.patch | 56 + 2 files changed, 70 insertions(+), 29 deletions(-) Modified: PKGBUILD === --- PKGBUILD2019-02-19 19:33:48 UTC (rev 434581) +++ PKGBUILD2019-02-19 19:38:05 UTC (rev 434582) @@ -1,51 +1,36 @@ # Maintainer: Felix Yan -pkgbase=python-astor -pkgname=('python-astor' 'python2-astor') +pkgname=python-astor pkgver=0.7.1 -pkgrel=1 +pkgrel=2 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') +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() { - cp -a astor-$pkgver{,-py2} + patch -d astor-$pkgver -p1 -i ../string-newline.patch } build() { - cd "$srcdir"/astor-$pkgver + cd 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 + cd astor-$pkgver + nosetests3 || warning "https://github.com/berkerpeksag/astor/issues/124; } -package_python-astor() { - depends=('python') - +package() { 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 -} Added: string-newline.patch === --- string-newline.patch(rev 0) +++ string-newline.patch2019-02-19 19:38:05 UTC (rev 434582) @@ -0,0 +1,56 @@ +commit 33f0e57bc84f0cd5cdf994127d81c99f2a23f659 +Author: Felix Yan +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:\nx = f'{host}\\n\\t{port}\\n'" != "if +1:\nx = 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' ++''' ++