cpython: 9ce5c1f371f7 (original) (raw)

Mercurial > cpython

changeset 96712:9ce5c1f371f7 3.4

Issue #20387: Merge [#20387]

Jason R. Coombs jaraco@jaraco.com
date Sun, 28 Jun 2015 11:10:29 -0400
parents fd17e168b59f(current diff)330e28b28334(diff)
children 98380a6e037c c95d7ffa492e
files Misc/NEWS
diffstat 3 files changed, 40 insertions(+), 1 deletions(-)[+] [-] Lib/test/test_tokenize.py 21 Lib/tokenize.py 17 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/test/test_tokenize.py +++ b/Lib/test/test_tokenize.py @@ -5,6 +5,8 @@ The tests can be really simple. Given a code, print out a table with tokens. The ENDMARKER is omitted for brevity.

+ >>> dump_tokens("1 + 1") ENCODING 'utf-8' (0, 0) (0, 0) NUMBER '1' (1, 0) (1, 1) @@ -647,7 +649,7 @@ from tokenize import (tokenize, _tokeniz open as tokenize_open, Untokenizer) from io import BytesIO from unittest import TestCase, mock -import os, sys, glob +import os import token def dump_tokens(s): @@ -1227,6 +1229,22 @@ class UntokenizeTest(TestCase): self.assertEqual(untokenize(iter(tokens)), b'Hello ') +class TestRoundtrip(TestCase):

+

+ + test = {"doctests" : doctests, 'decistmt': decistmt} def test_main(): @@ -1237,6 +1255,7 @@ def test_main(): support.run_unittest(TestDetectEncoding) support.run_unittest(TestTokenize) support.run_unittest(UntokenizeTest)

if name == "main": test_main()

--- a/Lib/tokenize.py +++ b/Lib/tokenize.py @@ -244,6 +244,8 @@ class Untokenizer: def untokenize(self, iterable): it = iter(iterable)

@@ -254,6 +256,21 @@ class Untokenizer: continue if tok_type == ENDMARKER: break

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -60,6 +60,9 @@ Core and Builtins Library ------- +- Issue #20387: Restore semantic round-trip correctness in tokenize/untokenize