Commit 6139c1a0 authored by Stefan Behnel's avatar Stefan Behnel

merge with latest cython-devel

parents 118c61fa 74dffa6f
...@@ -10,3 +10,4 @@ cdf889c30e7a7053de20bae3a578dad09ebcbdf5 0.10.3 ...@@ -10,3 +10,4 @@ cdf889c30e7a7053de20bae3a578dad09ebcbdf5 0.10.3
59c67af0674bd93c5fd8958e08c76a9dab9aae37 sage-cythonizes 59c67af0674bd93c5fd8958e08c76a9dab9aae37 sage-cythonizes
a4abf0156540db4d3ebaa95712b65811c43c5acb 0.11-beta a4abf0156540db4d3ebaa95712b65811c43c5acb 0.11-beta
838a6b7cae62e01dc0ce663cccab1f93f649fdbd 0.11.rc 838a6b7cae62e01dc0ce663cccab1f93f649fdbd 0.11.rc
4497f635d5fdbd38ebb841be4869fbfa2bbfdbb6 0.11.1.alpha
...@@ -1944,7 +1944,8 @@ class SliceIndexNode(ExprNode): ...@@ -1944,7 +1944,8 @@ class SliceIndexNode(ExprNode):
array_length = rhs.type.size array_length = rhs.type.size
self.generate_slice_guard_code(code, array_length) self.generate_slice_guard_code(code, array_length)
else: else:
error("Slice assignments from pointers are not yet supported.") error(self.pos,
"Slice assignments from pointers are not yet supported.")
# FIXME: fix the array size according to start/stop # FIXME: fix the array size according to start/stop
array_length = self.base.type.size array_length = self.base.type.size
for i in range(array_length): for i in range(array_length):
...@@ -2570,8 +2571,8 @@ class AttributeNode(ExprNode): ...@@ -2570,8 +2571,8 @@ class AttributeNode(ExprNode):
def compile_time_value(self, denv): def compile_time_value(self, denv):
attr = self.attribute attr = self.attribute
if attr.startswith("__") and attr.endswith("__"): if attr.startswith("__") and attr.endswith("__"):
self.error("Invalid attribute name '%s' in compile-time expression" error(self.pos,
% attr) "Invalid attribute name '%s' in compile-time expression" % attr)
return None return None
obj = self.obj.compile_time_value(denv) obj = self.obj.compile_time_value(denv)
try: try:
...@@ -5450,8 +5451,8 @@ static INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v ...@@ -5450,8 +5451,8 @@ static INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v
static INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int fits_long) { static INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int fits_long) {
if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) { if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
Py_DECREF(PyList_GET_ITEM(o, i));
Py_INCREF(v); Py_INCREF(v);
Py_DECREF(PyList_GET_ITEM(o, i));
PyList_SET_ITEM(o, i, v); PyList_SET_ITEM(o, i, v);
return 1; return 1;
} }
......
...@@ -256,6 +256,10 @@ class Context(object): ...@@ -256,6 +256,10 @@ class Context(object):
if debug_find_module: if debug_find_module:
print("......found ", pxd_pathname) print("......found ", pxd_pathname)
if not pxd_pathname and need_pxd: if not pxd_pathname and need_pxd:
package_pathname = self.search_include_directories(module_name, ".py", pos)
if package_pathname and package_pathname.endswith('__init__.py'):
pass
else:
error(pos, "'%s.pxd' not found" % module_name) error(pos, "'%s.pxd' not found" % module_name)
if pxd_pathname: if pxd_pathname:
try: try:
......
...@@ -531,6 +531,8 @@ class CFuncDeclaratorNode(CDeclaratorNode): ...@@ -531,6 +531,8 @@ class CFuncDeclaratorNode(CDeclaratorNode):
exc_val = None exc_val = None
exc_check = 0 exc_check = 0
if self.exception_check == '+':
env.add_include_file('stdexcept')
if return_type.is_pyobject \ if return_type.is_pyobject \
and (self.exception_value or self.exception_check) \ and (self.exception_value or self.exception_check) \
and self.exception_check != '+': and self.exception_check != '+':
...@@ -542,7 +544,6 @@ class CFuncDeclaratorNode(CDeclaratorNode): ...@@ -542,7 +544,6 @@ class CFuncDeclaratorNode(CDeclaratorNode):
exc_val = self.exception_value.get_constant_result_code() exc_val = self.exception_value.get_constant_result_code()
if self.exception_check == '+': if self.exception_check == '+':
exc_val_type = self.exception_value.type exc_val_type = self.exception_value.type
env.add_include_file('stdexcept')
if not exc_val_type.is_error and \ if not exc_val_type.is_error and \
not exc_val_type.is_pyobject and \ not exc_val_type.is_pyobject and \
not (exc_val_type.is_cfunction and not exc_val_type.return_type.is_pyobject and len(exc_val_type.args)==0): not (exc_val_type.is_cfunction and not exc_val_type.return_type.is_pyobject and len(exc_val_type.args)==0):
...@@ -1600,7 +1601,7 @@ class DefNode(FuncDefNode): ...@@ -1600,7 +1601,7 @@ class DefNode(FuncDefNode):
nogil = cfunc_type.nogil, nogil = cfunc_type.nogil,
visibility = 'private', visibility = 'private',
api = False, api = False,
directive_locals = cfunc.directive_locals) directive_locals = getattr(cfunc, 'directive_locals', {}))
def analyse_declarations(self, env): def analyse_declarations(self, env):
if 'locals' in env.directives: if 'locals' in env.directives:
...@@ -4530,6 +4531,10 @@ class FromCImportStatNode(StatNode): ...@@ -4530,6 +4531,10 @@ class FromCImportStatNode(StatNode):
elif kind == 'class': elif kind == 'class':
entry = module_scope.declare_c_class(name, pos = pos, entry = module_scope.declare_c_class(name, pos = pos,
module_name = self.module_name) module_name = self.module_name)
else:
submodule_scope = env.context.find_module(name, relative_to = module_scope, pos = self.pos)
if submodule_scope.parent_module is module_scope:
env.declare_module(as_name or name, submodule_scope, self.pos)
else: else:
error(pos, "Name '%s' not declared in module '%s'" error(pos, "Name '%s' not declared in module '%s'"
% (name, self.module_name)) % (name, self.module_name))
......
...@@ -812,6 +812,9 @@ class AlignFunctionDefinitions(CythonTransform): ...@@ -812,6 +812,9 @@ class AlignFunctionDefinitions(CythonTransform):
def visit_DefNode(self, node): def visit_DefNode(self, node):
pxd_def = self.scope.lookup(node.name) pxd_def = self.scope.lookup(node.name)
if pxd_def: if pxd_def:
if self.scope.is_c_class_scope and len(pxd_def.type.args) > 0:
# The self parameter type needs adjusting.
pxd_def.type.args[0].type = self.scope.parent_type
if pxd_def.is_cfunction: if pxd_def.is_cfunction:
node = node.as_cfunction(pxd_def) node = node.as_cfunction(pxd_def)
else: else:
......
...@@ -23,16 +23,20 @@ except NameError: ...@@ -23,16 +23,20 @@ except NameError:
possible_identifier = re.compile(ur"(?![0-9])\w+$", re.U).match possible_identifier = re.compile(ur"(?![0-9])\w+$", re.U).match
nice_identifier = re.compile('^[a-zA-Z0-0_]+$').match nice_identifier = re.compile('^[a-zA-Z0-0_]+$').match
ansi_c_keywords = set( iso_c99_keywords = set(
['auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do', ['auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do',
'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if', 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if',
'int', 'long', 'register', 'return', 'short', 'signed', 'sizeof', 'int', 'long', 'register', 'return', 'short', 'signed', 'sizeof',
'static', 'struct', 'switch', 'typedef', 'union', 'unsigned', 'void', 'static', 'struct', 'switch', 'typedef', 'union', 'unsigned', 'void',
'volatile', 'while']) 'volatile', 'while',
'_Bool', '_Complex'', _Imaginary', 'inline', 'restrict'])
def c_safe_identifier(cname): def c_safe_identifier(cname):
# There are some C limitations on struct entry names. # There are some C limitations on struct entry names.
if (cname[:2] == '__' and not cname.startswith(Naming.pyrex_prefix)) or cname in ansi_c_keywords: if ((cname[:2] == '__'
and not (cname.startswith(Naming.pyrex_prefix)
or cname == '__weakref__'))
or cname in iso_c99_keywords):
cname = Naming.pyrex_prefix + cname cname = Naming.pyrex_prefix + cname
return cname return cname
......
version = '0.11' version = '0.11.1.alpha'
cdef extern from "stdio.h": cdef extern from "stdio.h":
ctypedef struct FILE ctypedef struct FILE
int printf(char *format, ...) int printf(char *format, ...) nogil
int fprintf(FILE *stream, char *format, ...) int fprintf(FILE *stream, char *format, ...) nogil
int sprintf(char *str, char *format, ...) int sprintf(char *str, char *format, ...) nogil
FILE *fopen(char *path, char *mode) FILE *fopen(char *path, char *mode) nogil
int fclose(FILE *strea) int fclose(FILE *strea) nogil
cdef FILE *stdout cdef FILE *stdout
int scanf(char *format, ...) int scanf(char *format, ...) nogil
cdef extern from "stdlib.h": cdef extern from "stdlib.h":
void free(void *ptr) void free(void *ptr) nogil
void *malloc(size_t size) void *malloc(size_t size) nogil
void *realloc(void *ptr, size_t size) void *realloc(void *ptr, size_t size) nogil
size_t strlen(char *s) size_t strlen(char *s) nogil
char *strcpy(char *dest, char *src) char *strcpy(char *dest, char *src) nogil
cdef class A:
cpdef foo(self)
cdef class B(A):
cpdef foo(self)
class A:
def foo(self):
return "A"
class B(A):
def foo(self):
return "B"
cdef int **foo(void*)
from a cimport b
cdef int **t = b.foo(NULL)
cdef void raise_py_error():
pass
cdef extern from "foo.h":
cdef int generic_error() except +
cdef int specified_error() except +MemoryError
cdef int dynamic_error() except +raise_py_error
def test_it():
generic_error()
specified_error()
dynamic_error()
cdef void f(obj): cdef void f(obj):
cdef int i=0 cdef size_t i=0
cdef char *p cdef char *p
p = <char *>i p = <char *>i
p = <char *>&i p = <char *>&i
......
...@@ -65,10 +65,10 @@ def test_unsigned_long(): ...@@ -65,10 +65,10 @@ def test_unsigned_long():
cdef int i cdef int i
cdef unsigned long ix cdef unsigned long ix
cdef D = {} cdef D = {}
for i from 0 <= i < sizeof(unsigned long) * 8: for i from 0 <= i < <int>sizeof(unsigned long) * 8:
ix = (<unsigned long>1) << i ix = (<unsigned long>1) << i
D[ix] = True D[ix] = True
for i from 0 <= i < sizeof(unsigned long) * 8: for i from 0 <= i < <int>sizeof(unsigned long) * 8:
ix = (<unsigned long>1) << i ix = (<unsigned long>1) << i
assert D[ix] is True assert D[ix] is True
del D[ix] del D[ix]
...@@ -78,10 +78,10 @@ def test_unsigned_short(): ...@@ -78,10 +78,10 @@ def test_unsigned_short():
cdef int i cdef int i
cdef unsigned short ix cdef unsigned short ix
cdef D = {} cdef D = {}
for i from 0 <= i < sizeof(unsigned short) * 8: for i from 0 <= i < <int>sizeof(unsigned short) * 8:
ix = (<unsigned short>1) << i ix = (<unsigned short>1) << i
D[ix] = True D[ix] = True
for i from 0 <= i < sizeof(unsigned short) * 8: for i from 0 <= i < <int>sizeof(unsigned short) * 8:
ix = (<unsigned short>1) << i ix = (<unsigned short>1) << i
assert D[ix] is True assert D[ix] is True
del D[ix] del D[ix]
...@@ -91,10 +91,10 @@ def test_long_long(): ...@@ -91,10 +91,10 @@ def test_long_long():
cdef int i cdef int i
cdef long long ix cdef long long ix
cdef D = {} cdef D = {}
for i from 0 <= i < sizeof(long long) * 8: for i from 0 <= i < <int>sizeof(long long) * 8:
ix = (<long long>1) << i ix = (<long long>1) << i
D[ix] = True D[ix] = True
for i from 0 <= i < sizeof(long long) * 8: for i from 0 <= i < <int>sizeof(long long) * 8:
ix = (<long long>1) << i ix = (<long long>1) << i
assert D[ix] is True assert D[ix] is True
del D[ix] del D[ix]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment