-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Milestone
Description
Consider this:
$ cat mylib.pyx
#cython: embedsignature=True
def listdir(str path):
'''Print out *path*'''
print(path)
$ cython --version
Cython version 0.19
$ cython mylib.pyx; grep 'Print out' mylib.c | head -1
static char __pyx_doc_5mylib_listdir[= "listdir(str path)\nPrint out *path*";
$ cython -3 mylib.pyx; grep 'Print out' mylib.c | head -1
static char __pyx_doc_5mylib_listdir[](]) = "listdir(unicode path)\nPrint out *path*";
In other words, when running with -3
, the str
type in the function signature becomes unicode
.
I guess the idea is that when compiled for Python 2, the extension will expect a unicode object. However, when compiled under Python 3 (which is probably the more likely case), the signature is just confusing as there is no unicode type.
Moreover, the guess that under Python 2.x the function expects an unicode object is not necessarily correct. In my case, the function truly expects str in both Python 2.x and 3.x. Therefore, I think it would be just not rename any types when generating the docstring signature.
Migrated from http://trac.cython.org/ticket/812
McSinyx and juliusHuelsmann