Ticket #12719: trac-12719-always-preparse.patch

File trac-12719-always-preparse.patch, 1.6 KB (added by jason, 9 years ago)

apply to sage library

  • sage/misc/sage_extension.py

    # HG changeset patch
    # User Jason Grout <jason.grout@drake.edu>
    # Date 1354170461 21600
    # Node ID 51c690f793a44c8b8604b28da450dbe3ebf9b638
    # Parent  e0220350d70e6f4a1d4906c48ba9e9241fd6adc1
    Always preparse lines.
    
    The preparser is set up to know if it is in a string and maintain other state, so
    we should *always* call the preparser so it can maintain state.
    
    diff --git a/sage/misc/sage_extension.py b/sage/misc/sage_extension.py
    a b  
    357357                    buf[-1].rstrip().endswith((':', ',')) or buf[-1].lstrip().startswith('@')):
    358358                    for f in self.transforms:
    359359                        line = f(line, line_number)
     360                else:
     361                    for f in self.always_transform:
     362                        line = f(line, line_number)
    360363                out = push(line)
    361364        finally:
    362365            if changed_input_mode:
     
    483486        from sage.misc.interpreter import (SagePromptDedenter, SagePromptTransformer,
    484487                                           MagicTransformer, SagePreparseTransformer)
    485488
     489        p = SagePreparseTransformer()
    486490        self.shell.input_splitter.transforms = [SagePromptDedenter(),
    487491                                                SagePromptTransformer(),
    488492                                                MagicTransformer(),
    489                                                 SagePreparseTransformer()] + self.shell.input_splitter.transforms
     493                                                p] + self.shell.input_splitter.transforms
     494        self.shell.input_splitter.always_transform = [p]
    490495
    491496        preparser(True)
    492497