Ejemplo n.º 1
0
def test_full_chain():
    s = '"abc" #def\n  #ghi\nfrom  __future__ import (division as b, generators,);  from __future__ import with_statement\n'
    flags, pos = future.get_futures(future.futureFlags_2_5, s)
    assert flags == (fut.CO_FUTURE_DIVISION |
                     fut.CO_GENERATOR_ALLOWED |
                     fut.CO_FUTURE_WITH_STATEMENT)
    assert pos == (3, 55)
Ejemplo n.º 2
0
 def _compile_to_ast(self, source, info):
     from pypy.interpreter.pyparser.future import get_futures
     from pypy.interpreter.pyparser.error import (SyntaxError,
                                                  IndentationError,
                                                  TokenIndentationError)
     from pypy.interpreter.astcompiler.astbuilder import ast_from_node
     space = self.space
     try:
         f_flags, future_info = get_futures(self.future_flags, source)
         info.last_future_import = future_info
         info.flags |= f_flags
         parse_tree = self.parser.parse_source(source, info)
         mod = ast_from_node(space, parse_tree, info)
     except IndentationError, e:
         raise OperationError(space.w_IndentationError, e.wrap_info(space))
Ejemplo n.º 3
0
 def _compile_to_ast(self, source, info):
     from pypy.interpreter.pyparser.future import get_futures
     from pypy.interpreter.pyparser.error import (SyntaxError,
                                                  IndentationError,
                                                  TokenIndentationError)
     from pypy.interpreter.astcompiler.astbuilder import ast_from_node
     space = self.space
     try:
         f_flags, future_info = get_futures(self.future_flags, source)
         info.last_future_import = future_info
         info.flags |= f_flags
         parse_tree = self.parser.parse_source(source, info)
         mod = ast_from_node(space, parse_tree, info)
     except IndentationError, e:
         raise OperationError(space.w_IndentationError,
                              e.wrap_info(space))
Ejemplo n.º 4
0
def test_intervening_code():
    s = 'from  __future__ import (division as b, generators,)\nfrom sys import modules\nfrom __future__ import with_statement\n'
    flags, pos = future.get_futures(future.futureFlags_2_5, s)
    assert flags & fut.CO_FUTURE_WITH_STATEMENT == 0
    assert pos == (1, 0)
Ejemplo n.º 5
0
def test_full_chain():
    s = '"abc" #def\n  #ghi\nfrom  __future__ import (division as b, generators,);  from __future__ import with_statement\n'
    flags, pos = future.get_futures(future.futureFlags_2_5, s)
    assert flags == (fut.CO_FUTURE_DIVISION | fut.CO_GENERATOR_ALLOWED
                     | fut.CO_FUTURE_WITH_STATEMENT)
    assert pos == (3, 55)
Ejemplo n.º 6
0
def test_intervening_code():
    s = 'from  __future__ import (division as b, generators,)\nfrom sys import modules\nfrom __future__ import with_statement\n'
    flags, pos = future.get_futures(future.futureFlags_2_5, s)
    assert flags & fut.CO_FUTURE_WITH_STATEMENT == 0
    assert pos == (1, 0)