cpython/Lib/lib2to3
Eric Appelt 14e976e00e closes bpo-30117: fix lib2to3 ParserIdempotency test (GH-1242)
Fix two (in my opinion) spurious failure conditions in the lib2to3.tests.test_parser.TestParserIdempotency test_parser test.

    Use the same encoding found in the initial file to write a temp file for a diff. This retains the BOM if the encoding was initially utf-8-sig.

    If the file cannot be parsed using the normal grammar, try again with no print statement which should succeed for valid files using future print_function

For case (1), the driver was correctly handling a BOM in a utf-8 file, but then the test was not writing a comparison file using 'utf-8-sig' to diff against, so the BOM got removed. I don't think that is the fault of the parser, and lib2to3 will retain the BOM.

For case (2), lib2to3 pre-detects the use of from __future__ import print_function or allows the user to force this interpretation with a -p flag, and then selects a different grammar with the print statement removed. That makes the test cases unfair to this test as the driver itself doesn't know which grammar to use. As a minimal fix, the test will try using a grammar with the print statement, and if that fails fall back on a grammar without it. A more thorough handling of the idempotency test would to be to parse all files using both grammars and ignore if one of the two failed but otherwise check both. I didn't think this was necessary but can change.
2018-01-29 23:13:03 -08:00
..
fixes bpo-32046: Update 2to3 when converts operator.isCallable(obj). (#4417) 2017-11-28 11:26:56 -05:00
pgen2 correct wording (#4983) 2017-12-22 20:48:13 -08:00
tests closes bpo-30117: fix lib2to3 ParserIdempotency test (GH-1242) 2018-01-29 23:13:03 -08:00
__init__.py
__main__.py Merged revisions 88535 via svnmerge from 2011-02-24 01:41:46 +00:00
btm_matcher.py bpo-29957: change LBYL key lookup to dict.setdefault (#938) 2017-04-01 23:02:31 -07:00
btm_utils.py Issue #27076: Doc, comment and tests spelling fixes 2016-05-26 05:35:26 +00:00
fixer_base.py rm unused import 2016-12-05 22:30:55 -08:00
fixer_util.py closes bpo-27494: Fix 2to3 handling of trailing comma after a generator expression (#3771) 2017-10-05 00:10:09 -07:00
Grammar.txt bpo-30406: Make async and await proper keywords (#1669) 2017-10-05 23:24:46 -04:00
main.py Issue #22173: Update lib2to3 tests to use unittest test discovery. 2014-10-29 12:24:59 -05:00
patcomp.py remove unused import (#5040) 2017-12-28 23:24:40 -08:00
PatternGrammar.txt
pygram.py bpo-24960: use pkgutil.get_data in lib2to3 to read pickled grammar files (#4977) 2017-12-22 12:18:33 -08:00
pytree.py bpo-29776: Use decorator syntax for properties. (#585) 2017-03-19 08:40:32 +02:00
refactor.py bpo-29783: Replace codecs.open() with io.open() (#599) 2017-06-16 08:59:01 +02:00