Sage compiles
authorRobert Bradshaw <robertwb@math.washington.edu>
Wed, 13 Aug 2008 09:43:43 +0000 (02:43 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Wed, 13 Aug 2008 09:43:43 +0000 (02:43 -0700)
Cython/Compiler/ExprNodes.py
Cython/Compiler/Parsing.py
Cython/Compiler/Visitor.py
tests/run/cdef_opt.pxd [new file with mode: 0644]
tests/run/cdef_opt.pyx [new file with mode: 0644]

index 555827989ab26de5b5c061faa76fa675a0ce4218..1557084fdf11880e593cd6ef5182239ebfafc609 100644 (file)
@@ -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
index 73b9008a810dde06eb28ccc4a81c38936f4220ff..2607060e1ef901f2e414b89afd421e4dd36ec5f1 100644 (file)
@@ -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)
index 3da3403b45412002014449b65ebda37a4286a24c..0f6e826d89e480a3828715d924ee13fd869177ab 100644 (file)
@@ -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 (file)
index 0000000..fa16ad4
--- /dev/null
@@ -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 (file)
index 0000000..e1751fa
--- /dev/null
@@ -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