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
59c67af0674bd93c5fd8958e08c76a9dab9aae37 sage-cythonizes
a4abf0156540db4d3ebaa95712b65811c43c5acb 0.11-beta
838a6b7cae62e01dc0ce663cccab1f93f649fdbd 0.11.rc
4497f635d5fdbd38ebb841be4869fbfa2bbfdbb6 0.11.1.alpha
......@@ -1944,7 +1944,8 @@ class SliceIndexNode(ExprNode):
array_length = rhs.type.size
self.generate_slice_guard_code(code, array_length)
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
array_length = self.base.type.size
for i in range(array_length):
......@@ -2570,8 +2571,8 @@ class AttributeNode(ExprNode):
def compile_time_value(self, denv):
attr = self.attribute
if attr.startswith("__") and attr.endswith("__"):
self.error("Invalid attribute name '%s' in compile-time expression"
% attr)
error(self.pos,
"Invalid attribute name '%s' in compile-time expression" % attr)
return None
obj = self.obj.compile_time_value(denv)
try:
......@@ -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) {
if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
Py_DECREF(PyList_GET_ITEM(o, i));
Py_INCREF(v);
Py_DECREF(PyList_GET_ITEM(o, i));
PyList_SET_ITEM(o, i, v);
return 1;
}
......
......@@ -256,7 +256,11 @@ class Context(object):
if debug_find_module:
print("......found ", pxd_pathname)
if not pxd_pathname and need_pxd:
error(pos, "'%s.pxd' not found" % module_name)
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)
if pxd_pathname:
try:
if debug_find_module:
......
......@@ -531,6 +531,8 @@ class CFuncDeclaratorNode(CDeclaratorNode):
exc_val = None
exc_check = 0
if self.exception_check == '+':
env.add_include_file('stdexcept')
if return_type.is_pyobject \
and (self.exception_value or self.exception_check) \
and self.exception_check != '+':
......@@ -542,7 +544,6 @@ class CFuncDeclaratorNode(CDeclaratorNode):
exc_val = self.exception_value.get_constant_result_code()
if self.exception_check == '+':
exc_val_type = self.exception_value.type
env.add_include_file('stdexcept')
if not exc_val_type.is_error 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):
......@@ -1600,7 +1601,7 @@ class DefNode(FuncDefNode):
nogil = cfunc_type.nogil,
visibility = 'private',
api = False,
directive_locals = cfunc.directive_locals)
directive_locals = getattr(cfunc, 'directive_locals', {}))
def analyse_declarations(self, env):
if 'locals' in env.directives:
......@@ -4531,8 +4532,12 @@ class FromCImportStatNode(StatNode):
entry = module_scope.declare_c_class(name, pos = pos,
module_name = self.module_name)
else:
error(pos, "Name '%s' not declared in module '%s'"
% (name, self.module_name))
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:
error(pos, "Name '%s' not declared in module '%s'"
% (name, self.module_name))
if entry:
local_name = as_name or name
......
......@@ -812,6 +812,9 @@ class AlignFunctionDefinitions(CythonTransform):
def visit_DefNode(self, node):
pxd_def = self.scope.lookup(node.name)
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:
node = node.as_cfunction(pxd_def)
else:
......
......@@ -23,16 +23,20 @@ except NameError:
possible_identifier = re.compile(ur"(?![0-9])\w+$", re.U).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',
'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if',
'int', 'long', 'register', 'return', 'short', 'signed', 'sizeof',
'static', 'struct', 'switch', 'typedef', 'union', 'unsigned', 'void',
'volatile', 'while'])
'volatile', 'while',
'_Bool', '_Complex'', _Imaginary', 'inline', 'restrict'])
def c_safe_identifier(cname):
# 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:
# There are some C limitations on struct entry names.
if ((cname[:2] == '__'
and not (cname.startswith(Naming.pyrex_prefix)
or cname == '__weakref__'))
or cname in iso_c99_keywords):
cname = Naming.pyrex_prefix + cname
return cname
......
version = '0.11'
version = '0.11.1.alpha'
cdef extern from "stdio.h":
ctypedef struct FILE
int printf(char *format, ...)
int fprintf(FILE *stream, char *format, ...)
int sprintf(char *str, char *format, ...)
FILE *fopen(char *path, char *mode)
int fclose(FILE *strea)
int printf(char *format, ...) nogil
int fprintf(FILE *stream, char *format, ...) nogil
int sprintf(char *str, char *format, ...) nogil
FILE *fopen(char *path, char *mode) nogil
int fclose(FILE *strea) nogil
cdef FILE *stdout
int scanf(char *format, ...)
int scanf(char *format, ...) nogil
cdef extern from "stdlib.h":
void free(void *ptr)
void *malloc(size_t size)
void *realloc(void *ptr, size_t size)
size_t strlen(char *s)
char *strcpy(char *dest, char *src)
void free(void *ptr) nogil
void *malloc(size_t size) nogil
void *realloc(void *ptr, size_t size) nogil
size_t strlen(char *s) nogil
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 int i=0
cdef size_t i=0
cdef char *p
p = <char *>i
p = <char *>&i
......
......@@ -65,10 +65,10 @@ def test_unsigned_long():
cdef int i
cdef unsigned long ix
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
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
assert D[ix] is True
del D[ix]
......@@ -78,10 +78,10 @@ def test_unsigned_short():
cdef int i
cdef unsigned short ix
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
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
assert D[ix] is True
del D[ix]
......@@ -91,10 +91,10 @@ def test_long_long():
cdef int i
cdef long long ix
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
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
assert D[ix] is True
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