Skip to content

Instantly share code, notes, and snippets.

@robertwb
Created August 16, 2016 08:50
Show Gist options
  • Save robertwb/dd3f7cd98846f9d54dc6ba012ffa2253 to your computer and use it in GitHub Desktop.
Save robertwb/dd3f7cd98846f9d54dc6ba012ffa2253 to your computer and use it in GitHub Desktop.
Attachment embedsignature.patch for http://trac.cython.org/ticket/181
# HG changeset patch
# User Jason Evans <jasone@canonware.com>
# Date 1231908744 28800
# Node ID 51cbef6228bc0336c57a65e0824005eaeae96fd2
# Parent f51f733b41b8173a08d4e6f16b9ac38527c3de0b
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
--- a/Cython/Compiler/AutoDocTransforms.py
+++ b/Cython/Compiler/AutoDocTransforms.py
@@ -21,7 +21,7 @@
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
--- a/tests/run/embedsignatures.pyx
+++ b/tests/run/embedsignatures.pyx
@@ -36,6 +36,9 @@
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
@@ -63,6 +66,12 @@
>>> 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 @@
"""Existing string"""
pass
+ def m(self, a='spam'):
+ pass
+
cpdef int get_int(self):
return 0
@@ -203,6 +215,12 @@
"""
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment