From: Stefan Behnel Date: Wed, 30 Jun 2010 20:05:58 +0000 (+0200) Subject: always use decoded filenames in FileSourceDescriptor X-Git-Tag: 0.13.beta0~43 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=bcfa729f32fa8eab7cd5ef23175bbb63fe29c3d5;p=cython.git always use decoded filenames in FileSourceDescriptor --- diff --git a/Cython/Compiler/Annotate.py b/Cython/Compiler/Annotate.py index d2dbb6a0..425d956e 100644 --- a/Cython/Compiler/Annotate.py +++ b/Cython/Compiler/Annotate.py @@ -127,7 +127,7 @@ function toggleDiv(id) { """) f.write(u'\n') f.write(u'

Generated by Cython %s on %s\n' % (Version.version, time.asctime())) - c_file = Utils.encode_filename(os.path.basename(target_filename)) + c_file = Utils.decode_filename(os.path.basename(target_filename)) f.write(u'

Raw output: %s\n' % (c_file, c_file)) k = 0 diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py index b06b116d..a9c7c3b8 100644 --- a/Cython/Compiler/Main.py +++ b/Cython/Compiler/Main.py @@ -479,7 +479,7 @@ class Context(object): def parse(self, source_desc, scope, pxd, full_module_name): if not isinstance(source_desc, FileSourceDescriptor): raise RuntimeError("Only file sources for code supported") - source_filename = Utils.encode_filename(source_desc.filename) + source_filename = source_desc.filename scope.cpp = self.cpp # Parse the given source file and return a parse tree. try: diff --git a/Cython/Compiler/Scanning.py b/Cython/Compiler/Scanning.py index 7e99b773..44a27315 100644 --- a/Cython/Compiler/Scanning.py +++ b/Cython/Compiler/Scanning.py @@ -166,6 +166,7 @@ class FileSourceDescriptor(SourceDescriptor): the position()-tuple. """ def __init__(self, filename): + filename = Utils.decode_filename(filename) self.filename = filename self.set_file_type_from_name(filename) self._cmp_name = filename diff --git a/Cython/Utils.py b/Cython/Utils.py index 48877c7b..deaab7ff 100644 --- a/Cython/Utils.py +++ b/Cython/Utils.py @@ -66,9 +66,9 @@ def path_exists(path): pass return False -# support for source file encoding detection +# file name encodings -def encode_filename(filename): +def decode_filename(filename): if isinstance(filename, unicode): return filename try: @@ -80,6 +80,8 @@ def encode_filename(filename): pass return filename +# support for source file encoding detection + _match_file_encoding = re.compile(u"coding[:=]\s*([-\w.]+)").search def detect_file_encoding(source_filename):