Correct handling "if" in dictcomp in semantic actions for 3.x

This commit is contained in:
rocky
2020-01-15 02:36:19 -05:00
parent 3c2dafe74c
commit 5cdf057a47
10 changed files with 19 additions and 12 deletions

View File

@@ -3,12 +3,24 @@
# #
# This code is RUNNABLE! # This code is RUNNABLE!
def x(s): def x(s):
return {k: v return {k: v for (k, v) in s if not k.startswith("_")}
for (k, v) in s
if not k.startswith('_')
}
# Yes, the print() is funny. This is # Yes, the print() is funny. This is
# to test though a 2-arg assert where # to test though a 2-arg assert where
# the 2nd argument is not a string. # the 2nd argument is not a string.
assert x((('_foo', None),)) == {}, print("See issue #162") assert x((("_foo", None),)) == {}, print("See issue #162")
# From 3.7 test_dictcomps.py
assert {k: v for k in range(10) for v in range(10) if k == v} == {
0: 0,
1: 1,
2: 2,
3: 3,
4: 4,
5: 5,
6: 6,
7: 7,
8: 8,
9: 9,
}

View File

@@ -5,7 +5,6 @@ SKIP_TESTS=(
[test_concurrent_futures.py]=1 # too long? [test_concurrent_futures.py]=1 # too long?
[test_decimal.py]=1 # test takes too long to run: 18 seconds [test_decimal.py]=1 # test takes too long to run: 18 seconds
[test_descr.py]=1 # test assertion errors [test_descr.py]=1 # test assertion errors
[test_dictcomps.py]=1 # test assertion errors
[test_doctest.py]=1 # test assertion errors [test_doctest.py]=1 # test assertion errors
[test_doctest2.py]=1 # test assertion errors [test_doctest2.py]=1 # test assertion errors
[test_dis.py]=1 # We change line numbers - duh! [test_dis.py]=1 # We change line numbers - duh!

View File

@@ -21,7 +21,6 @@ SKIP_TESTS=(
[test_decimal.py]=1 # test takes too long to run: 18 seconds [test_decimal.py]=1 # test takes too long to run: 18 seconds
[test_devpoll.py]=1 # it fails on its own [test_devpoll.py]=1 # it fails on its own
[test_descr.py]=1 # Doesn't terminate [test_descr.py]=1 # Doesn't terminate
[test_dictcomps.py]=1 # test assertion failure
[test_dict.py]=1 # [test_dict.py]=1 #
[test_dis.py]=1 # We change line numbers - duh! [test_dis.py]=1 # We change line numbers - duh!
[test_distutils.py]=1 # it fails on its own [test_distutils.py]=1 # it fails on its own

View File

@@ -32,7 +32,6 @@ SKIP_TESTS=(
[test_devpoll.py]=1 # it fails on its own [test_devpoll.py]=1 # it fails on its own
[test_dict.py]=1 # [test_dict.py]=1 #
[test_dictcomps.py]=1 # test assertion failure
[test_dis.py]=1 # We change line numbers - duh! [test_dis.py]=1 # We change line numbers - duh!
[test_distutils.py]=1 # it fails on its own [test_distutils.py]=1 # it fails on its own
[test_dbm_gnu.py]=1 # Doesn't terminate [test_dbm_gnu.py]=1 # Doesn't terminate

View File

@@ -51,7 +51,6 @@ SKIP_TESTS=(
[test_descr.py]=1 # syntax error: Investigate [test_descr.py]=1 # syntax error: Investigate
[test_devpoll.py]=1 # it fails on its own [test_devpoll.py]=1 # it fails on its own
[test_dict.py]=1 # it fails on its own [test_dict.py]=1 # it fails on its own
[test_dictcomps.py]=1 # We change line numbers - duh!
[test_dis.py]=1 # We change line numbers - duh! [test_dis.py]=1 # We change line numbers - duh!
[test_doctest2.py]=1 # [test_doctest2.py]=1 #
[test_doctest.py]=1 # [test_doctest.py]=1 #

View File

@@ -31,7 +31,6 @@ SKIP_TESTS=(
[test_decimal.py]=1 # Parse error [test_decimal.py]=1 # Parse error
[test_descr.py]=1 # Parse error [test_descr.py]=1 # Parse error
[test_devpoll.py]=1 # it fails on its own [test_devpoll.py]=1 # it fails on its own
[test_dictcomps.py]=1 # Bad semantics - Investigate
[test_dis.py]=1 # We change line numbers - duh! [test_dis.py]=1 # We change line numbers - duh!
[test_doctest2.py]=1 # assert failure [test_doctest2.py]=1 # assert failure
[test_docxmlrpc.py]=1 [test_docxmlrpc.py]=1

View File

@@ -274,7 +274,7 @@ fi
PYENV_ROOT=${PYENV_ROOT:-$HOME/.pyenv} PYENV_ROOT=${PYENV_ROOT:-$HOME/.pyenv}
pyenv_local=$(pyenv local) pyenv_local=$(pyenv local)
# pyenv version cleaning # pyenv version update
for dir in ../ ../../ ; do for dir in ../ ../../ ; do
cp -v .python-version $dir cp -v .python-version $dir
done done

View File

@@ -1333,7 +1333,7 @@ class SourceWalker(GenericASTTraversal, object):
if comp_store: if comp_store:
self.preorder(comp_for) self.preorder(comp_for)
elif if_node: if if_node:
self.write(" if ") self.write(" if ")
if have_not: if have_not:
self.write("not ") self.write("not ")