From: Robert Bradshaw Date: Wed, 13 Aug 2008 03:57:43 +0000 (-0700) Subject: merge dag and devel branches X-Git-Tag: 0.9.8.1~49^2~5^2~6 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=82acc1f83d5cf76d17dd8211954c2ca6b2bc499f;p=cython.git merge dag and devel branches --- 82acc1f83d5cf76d17dd8211954c2ca6b2bc499f diff --cc Cython/Compiler/Buffer.py index 6361e619,45cb8196..caeb12f6 --- a/Cython/Compiler/Buffer.py +++ b/Cython/Compiler/Buffer.py @@@ -5,17 -5,14 +5,22 @@@ from Cython.Compiler.ExprNodes import from Cython.Compiler.TreeFragment import TreeFragment from Cython.Utils import EncodedString from Cython.Compiler.Errors import CompileError +import Interpreter import PyrexTypes - from sets import Set as set + + try: + set + except NameError: + from sets import Set as set + import textwrap + +# Code cleanup ideas: +# - One could be more smart about casting in some places +# - Start using CCodeWriters to generate utility functions +# - Create a struct type per ndim rather than keeping loose local vars + + def dedent(text, reindent=0): text = textwrap.dedent(text) if reindent > 0: diff --cc Cython/Compiler/CmdLine.py index c218fce4,c149f355..52f76080 --- a/Cython/Compiler/CmdLine.py +++ b/Cython/Compiler/CmdLine.py @@@ -34,10 -35,9 +35,10 @@@ Options are searched from) -D, --no-docstrings Remove docstrings. - -a, --annotate Produce an colorized version of the source. + -a, --annotate Produce a colorized HTML version of the source. --convert-range Convert for loops using range() function to for...from loops. --cplus Output a c++ rather than c file. + -O, --option =[, 0: self.level += dl - elif dl == 0 and code.startswith('}'): + elif fix_indent: self.level += 1 + return self def increase_indent(self): self.level = self.level + 1 diff --cc Cython/Compiler/Lexicon.py index 8fe3724f,e3f1be9a..60c5bd88 --- a/Cython/Compiler/Lexicon.py +++ b/Cython/Compiler/Lexicon.py @@@ -64,9 -64,9 +64,10 @@@ def make_lexicon() two_hex = hexdigit + hexdigit four_hex = two_hex + two_hex escapeseq = Str("\\") + (two_oct | three_oct | two_hex | - Str('u') + four_hex | Str('x') + two_hex | AnyChar) + Str('u') + four_hex | Str('x') + two_hex | + Str('U') + four_hex + four_hex | AnyChar) + deco = Str("@") bra = Any("([{") ket = Any(")]}") diff --cc Cython/Compiler/Main.py index 79aee18a,55b031e1..7d68ded1 --- a/Cython/Compiler/Main.py +++ b/Cython/Compiler/Main.py @@@ -477,19 -407,9 +479,12 @@@ def create_default_resultobj(compilatio else: c_suffix = ".c" result.c_file = Utils.replace_suffix(source_desc.filename, c_suffix) - # The below doesn't make any sense? Why is it there? - c_stat = None - if result.c_file: - try: - c_stat = os.stat(result.c_file) - except EnvironmentError: - pass return result -def run_pipeline(source, context, options, full_module_name = None): +def run_pipeline(source, options, full_module_name = None): + # Set up context + context = Context(options.include_path, options.pragma_overrides) + # Set up source object cwd = os.getcwd() source_desc = FileSourceDescriptor(os.path.join(cwd, source)) @@@ -614,9 -533,10 +609,7 @@@ def compile_single(source, options, ful Always compiles a single file; does not perform timestamp checking or recursion. """ - context = Context(options.include_path) - return run_pipeline(source, context, options, full_module_name) -# context = Context(options.include_path) -# return context.compile(source, options, full_module_name) + return run_pipeline(source, options, full_module_name) - # context = Context(options.include_path) - # return context.compile(source, options, full_module_name) def compile_multiple(sources, options): @@@ -642,9 -564,7 +637,7 @@@ if verbose: sys.stderr.write("Compiling %s\n" % source) - result = context.compile(source, options) - # Compiling multiple sources in one context doesn't quite - # work properly yet. - result = run_pipeline(source, context, options) ++ result = run_pipeline(source, options) results.add(source, result) processed.add(source) if recursive: diff --cc Cython/Compiler/ParseTreeTransforms.py index 833f9bdd,a775f766..28403909 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@@ -5,8 -5,10 +5,11 @@@ from Cython.Compiler.ExprNodes import from Cython.Compiler.TreeFragment import TreeFragment from Cython.Utils import EncodedString from Cython.Compiler.Errors import CompileError - from sets import Set as set + try: + set + except NameError: + from sets import Set as set +import copy class NormalizeTree(CythonTransform): """ diff --cc Cython/StringIOTree.py index 4178b108,9e9b31b2..5d07a5c8 --- a/Cython/StringIOTree.py +++ b/Cython/StringIOTree.py @@@ -81,29 -55,15 +78,13 @@@ EXAMPLE >>> d.write('alpha\n') >>> b.write('gamma\n') >>> c.write('beta\n') - >>> print b.getvalue() - second - alpha - beta - gamma - - + >>> b.getvalue().split() + ['second', 'alpha', 'beta', 'gamma'] - +>>> i = StringIOTree() +>>> d.insert(i) +>>> i.write('inserted\n') >>> out = StringIO() >>> a.copyto(out) - >>> print out.getvalue() - first - second - alpha - inserted - beta - gamma - third - - """ - - if __name__ == "__main__": - import doctest - doctest.testmod() + >>> out.getvalue().split() -['first', 'second', 'alpha', 'beta', 'gamma', 'third'] -""" - -if __name__ == "__main__": - import doctest - doctest.testmod() ++['first', 'second', 'alpha', 'inserted', 'beta', 'gamma', 'third'] ++"""