~ubuntu-branches/ubuntu/precise/python3.2/precise-proposed

« back to all changes in this revision

Viewing changes to Lib/lib2to3/pgen2/driver.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-03-09 18:40:39 UTC
  • mfrom: (30.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120309184039-j3yk2emxr1plyo21
Tags: 3.2.3~rc1-1
* Python 3.2.3 release candidate 1.
* Update to 20120309 from the 3.2 branch.
* Fix libpython.a symlink. Closes: #660146.
* Build-depend on xauth.
* Run the gdb tests for the debug build only.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
# Python imports
19
19
import codecs
 
20
import io
20
21
import os
21
22
import logging
22
23
import sys
101
102
 
102
103
    def parse_string(self, text, debug=False):
103
104
        """Parse a string and return the syntax tree."""
104
 
        tokens = tokenize.generate_tokens(generate_lines(text).__next__)
 
105
        tokens = tokenize.generate_tokens(io.StringIO(text).readline)
105
106
        return self.parse_tokens(tokens, debug)
106
107
 
107
108
 
108
 
def generate_lines(text):
109
 
    """Generator that behaves like readline without using StringIO."""
110
 
    for line in text.splitlines(True):
111
 
        yield line
112
 
    while True:
113
 
        yield ""
114
 
 
115
 
 
116
109
def load_grammar(gt="Grammar.txt", gp=None,
117
110
                 save=True, force=False, logger=None):
118
111
    """Load the grammar (maybe from a pickle)."""