From 05d0a3756abb31a6a599430e5621041c9b1693ae Mon Sep 17 00:00:00 2001
From: Jason Evans <jasone@canonware.com>
Date: Tue, 13 Jan 2009 20:52:24 -0800
Subject: [PATCH] Print default arguments syntactically, in order to (for
 example) preserve quotes around strings.

---
 Cython/Compiler/AutoDocTransforms.py |  2 +-
 tests/run/embedsignatures.pyx        | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/Cython/Compiler/AutoDocTransforms.py b/Cython/Compiler/AutoDocTransforms.py
index dae5926bd..738759845 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 f4c8d2a13..6dca09aac 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
 
-- 
2.30.9