From: Robert Bradshaw Date: Wed, 13 Aug 2008 09:43:43 +0000 (-0700) Subject: Sage compiles X-Git-Tag: 0.9.8.1~49^2~5^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6a774aad4315e8fcbf589dda3d46af109b256fa8;p=cython.git Sage compiles --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 55582798..1557084f 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -708,8 +708,7 @@ class StringNode(ConstNode): def coerce_to(self, dst_type, env): if dst_type.is_int: if not self.type.is_pyobject and len(self.entry.init) == 1: - # we use the *encoded* value here - return CharNode(self.pos, value=self.entry.init) + return CharNode(self.pos, value=self.value) else: error(self.pos, "Only coerce single-character ascii strings can be used as ints.") return self diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 73b9008a..2607060e 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -1888,7 +1888,7 @@ def p_c_arg_decl(s, ctx, in_pyfunc, cmethod_flag = 0, nonempty = 0, kw_only = 0) if 'pxd' in s.level: if s.sy not in ['*', '?']: error(pos, "default values cannot be specified in pxd files, use ? or *") - default = 1 + default = ExprNodes.BoolNode(1) s.next() else: default = p_simple_expr(s) diff --git a/Cython/Compiler/Visitor.py b/Cython/Compiler/Visitor.py index 3da3403b..0f6e826d 100644 --- a/Cython/Compiler/Visitor.py +++ b/Cython/Compiler/Visitor.py @@ -28,6 +28,10 @@ class BasicVisitor(object): if m is not None: break else: + print type(self), type(obj) + print self.access_path + print self.access_path[-1][0].pos + print self.access_path[-1][0].__dict__ raise RuntimeError("Visitor does not accept object: %s" % obj) self.dispatch_table[mname] = m return m(obj) diff --git a/tests/run/cdef_opt.pxd b/tests/run/cdef_opt.pxd new file mode 100644 index 00000000..fa16ad40 --- /dev/null +++ b/tests/run/cdef_opt.pxd @@ -0,0 +1,2 @@ +cdef class A: + cpdef foo(self, bint a=*, b=*) diff --git a/tests/run/cdef_opt.pyx b/tests/run/cdef_opt.pyx new file mode 100644 index 00000000..e1751fa1 --- /dev/null +++ b/tests/run/cdef_opt.pyx @@ -0,0 +1,13 @@ +__doc__ = """ + >>> a = A() + >>> a.foo() + (True, 'yo') + >>> a.foo(False) + (False, 'yo') + >>> a.foo(10, 'yes') + (True, 'yes') +""" + +cdef class A: + cpdef foo(self, bint a=True, b="yo"): + return a, b