From: Jason Evans Date: Wed, 14 Jan 2009 04:52:24 +0000 (-0800) Subject: Print default arguments syntactically, in order to (for example) preserve X-Git-Tag: 0.11-beta~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=05d0a3756abb31a6a599430e5621041c9b1693ae;p=cython.git Print default arguments syntactically, in order to (for example) preserve quotes around strings. --- diff --git a/Cython/Compiler/AutoDocTransforms.py b/Cython/Compiler/AutoDocTransforms.py index dae5926b..73875984 100644 --- a/Cython/Compiler/AutoDocTransforms.py +++ b/Cython/Compiler/AutoDocTransforms.py @@ -21,7 +21,7 @@ class EmbedSignature(CythonTransform): try: denv = self.denv # XXX ctval = arg.default.compile_time_value(self.denv) - return '%s' % ctval + return '%r' % ctval except Exception: try: return arg.default.name # XXX diff --git a/tests/run/embedsignatures.pyx b/tests/run/embedsignatures.pyx index f4c8d2a1..6dca09aa 100644 --- a/tests/run/embedsignatures.pyx +++ b/tests/run/embedsignatures.pyx @@ -36,6 +36,9 @@ __doc__ = ur""" Ext.l(self, a, b, c=1, *args, d=42, e=17, f, **kwds) Existing string + >>> print (Ext.m.__doc__) + Ext.m(self, a='spam') + >>> print (Ext.get_int.__doc__) Ext.get_int(self) -> int @@ -64,6 +67,12 @@ __doc__ = ur""" >>> with_doc_4.__doc__ 'with_doc_4(int a, str b, list c) -> str\n\n Existing string\n ' + >>> f_sd.__doc__ + "f_sd(str s='spam')" + + >>> cf_sd.__doc__ + "cf_sd(str s='spam') -> str" + >>> types.__doc__ 'types(Ext a, int b, unsigned short c, float d, e)' @@ -164,6 +173,9 @@ cdef class Ext: """Existing string""" pass + def m(self, a='spam'): + pass + cpdef int get_int(self): return 0 @@ -203,6 +215,12 @@ cpdef str with_doc_4(int a, str b, list c): """ return b +def f_sd(str s='spam'): + return s + +cpdef str cf_sd(str s='spam'): + return s + cpdef char f_c(char c): return c