Dschoni
Dschoni

Reputation: 3872

Compiling Cython .pyx files on a non-english Ubuntu (unicode error)

So, I guess this is a bug in one of the involved packets and I want to report it, but I don't really understand where exactly the error is so I'm trying to define it and describe the solution.

I recently upgraded to Ubuntu 14.4 and was very happy to be able to use it in my own language, when I ran into an error, which is due to the language changes:

When trying to compile cython .pyx files using distutils, the compilation aborts with a unicode error, if the files are in a path, which includes non-ascii symbols. In my case the desktop path has been renamed to the german version "Arbeitsfläche", where there seem to be problems when compiling.

Can anybody tell me if this is a bug or a feature (and if the former, where to submit)?

Stack trace for completeness:

Compiler crash traceback from this point on:
  File "/usr/lib/python2.7/dist-packages/Cython/Compiler/Nodes.py", line 6785, in analyse_declarations
    module_scope = env.find_module(self.module_name, self.pos)
  File "/usr/lib/python2.7/dist-packages/Cython/Compiler/Symtab.py", line 1089, in find_module
    module_name, relative_to = self.parent_module, pos = pos)
  File "/usr/lib/python2.7/dist-packages/Cython/Compiler/Main.py", line 132, in find_module
    pxd_pathname = self.find_pxd_file(qualified_name, pos)
  File "/usr/lib/python2.7/dist-packages/Cython/Compiler/Main.py", line 184, in find_pxd_file
    pxd = self.search_include_directories(qualified_name, ".pxd", pos, sys_path=True)
  File "/usr/lib/python2.7/dist-packages/Cython/Compiler/Main.py", line 225, in search_include_directories
    tuple(self.include_directories), qualified_name, suffix, pos, include, sys_path)
  File "/usr/lib/python2.7/dist-packages/Cython/Utils.py", line 16, in wrapper
    res = cache[args] = f(*args)
  File "/usr/lib/python2.7/dist-packages/Cython/Utils.py", line 101, in search_include_directories
    path = os.path.join(dir, dotted_filename)
  File "/usr/lib/python2.7/posixpath.py", line 80, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 23: ordinal not in range(128)

Edit 18.8.2014

A minimal example can be found here. It seems, that the import cython statement triggers the behaviour.

Upvotes: 2

Views: 613

Answers (1)

Phillip
Phillip

Reputation: 13678

I've managed to compile your example after I replaced the arguments to setup

ext_modules=linext,
cmdclass = {'build_ext': build_ext}

with the version that is encouraged in the current cython documentation:

ext_modules=cythonize(linext)

Depending on where you've found your version, there either really is a bug in Cython, or you simply tried something which does not work.

Upvotes: 1

Related Questions