From 206dc3aafcd920faf3f6322414e75f2719ffdac1 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sun, 24 Jan 2016 16:44:05 -0800 Subject: [PATCH] Add python 3 compatibility check for libmodernize.fixes.fix_dict_six. It's not clear whether this will end up being net negative in value in the long term since it's kinda hard to understand the output, but in the short term it should prevent regressions. --- tools/travis/py3k | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/travis/py3k b/tools/travis/py3k index 547c5fcb5c..6ccb6ecfc1 100755 --- a/tools/travis/py3k +++ b/tools/travis/py3k @@ -56,6 +56,30 @@ for fixer in $fixers; do fi done +# The dict fixer tries to add list() even in for loops over an +# iterator where it's just counterproductive. To address this, we run +# the fixer but check for lines which don't include code that works +# with iterators (currently for, join, and from_iterable). +fixer="libmodernize.fixes.fix_dict_six" +echo "Running python 3 compatability test $fixer" +python-modernize -f $fixer -j4 -n -w . >/dev/null 2>/dev/null +if git diff | grep "^+ " | grep -v '[ ]*for' | grep -v [.]join | grep -v from_iterable; then + echo + echo "Error: the above are changes suggested by python-modernize " + echo "to handle the list=>iterator transition in Python 3." + echo "Because 'python-modernize -f libmodernize.fixes.fix_dict_six' is spammy " + echo "and also changes places where an iterator works fine, this output " + echo "does not display the full context; you can find the diff with context by " + echo "searching through the (unfortunately very spammy) full output below:" + echo + # Clear the output + git diff + echo + echo "That was a lot of text! Read this output from the top for more readable details." + git reset --hard >/dev/null + failed=1 +fi + if git grep -q '\(^\W*import StringIO\|^\W*from StringIO\)'; then echo "ERROR: StringIO imports not compatible with python 2+3:" git grep '\(^\W*import StringIO\|^\W*from StringIO\)'