Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
c35599ce
Commit
c35599ce
authored
Aug 15, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix lots of tests errors, all tests pass.
parent
f77650eb
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
33 deletions
+45
-33
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-11
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+0
-4
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+17
-3
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+20
-10
tests/errors/e_bufaccess.pyx
tests/errors/e_bufaccess.pyx
+2
-2
tests/errors/e_del.pyx
tests/errors/e_del.pyx
+3
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
c35599ce
...
@@ -2429,14 +2429,6 @@ class SimpleCallNode(CallNode):
...
@@ -2429,14 +2429,6 @@ class SimpleCallNode(CallNode):
self
.
function
.
entry
=
entry
self
.
function
.
entry
=
entry
self
.
function
.
type
=
entry
.
type
self
.
function
.
type
=
entry
.
type
func_type
=
self
.
function_type
()
func_type
=
self
.
function_type
()
# Check function type
if
not
func_type
.
is_cfunction
:
if
not
func_type
.
is_error
:
error
(
self
.
pos
,
"Calling non-function type '%s'"
%
func_type
)
self
.
type
=
PyrexTypes
.
error_type
self
.
result_code
=
"<error>"
return
# Check no. of args
# Check no. of args
max_nargs
=
len
(
func_type
.
args
)
max_nargs
=
len
(
func_type
.
args
)
expected_nargs
=
max_nargs
-
func_type
.
optional_arg_count
expected_nargs
=
max_nargs
-
func_type
.
optional_arg_count
...
@@ -2479,7 +2471,7 @@ class SimpleCallNode(CallNode):
...
@@ -2479,7 +2471,7 @@ class SimpleCallNode(CallNode):
def
c_call_code
(
self
):
def
c_call_code
(
self
):
func_type
=
self
.
function_type
()
func_type
=
self
.
function_type
()
if
self
.
args
is
Non
e
or
not
func_type
.
is_cfunction
:
if
self
.
type
is
PyrexTypes
.
error_typ
e
or
not
func_type
.
is_cfunction
:
return
"<error>"
return
"<error>"
formal_args
=
func_type
.
args
formal_args
=
func_type
.
args
arg_list_code
=
[]
arg_list_code
=
[]
...
@@ -3772,8 +3764,8 @@ class UnopNode(ExprNode):
...
@@ -3772,8 +3764,8 @@ class UnopNode(ExprNode):
self
.
type
=
py_object_type
self
.
type
=
py_object_type
self
.
gil_check
(
env
)
self
.
gil_check
(
env
)
self
.
is_temp
=
1
self
.
is_temp
=
1
elif
self
.
is_cpp_operation
:
elif
self
.
is_cpp_operation
()
:
self
.
analyse_cpp_operation
self
.
analyse_cpp_operation
(
env
)
else
:
else
:
self
.
analyse_c_operation
(
env
)
self
.
analyse_c_operation
(
env
)
...
...
Cython/Compiler/Nodes.py
View file @
c35599ce
...
@@ -775,9 +775,6 @@ class TemplatedTypeNode(CBaseTypeNode):
...
@@ -775,9 +775,6 @@ class TemplatedTypeNode(CBaseTypeNode):
else
:
else
:
if
not
isinstance
(
env
,
Symtab
.
LocalScope
):
error
(
self
.
pos
,
ERR_BUF_LOCALONLY
)
import
Buffer
import
Buffer
options
=
Buffer
.
analyse_buffer_options
(
options
=
Buffer
.
analyse_buffer_options
(
...
@@ -5817,4 +5814,3 @@ proto="""
...
@@ -5817,4 +5814,3 @@ proto="""
#------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------
ERR_BUF_LOCALONLY
=
'Buffer types only allowed as function local variables'
Cython/Compiler/PyrexTypes.py
View file @
c35599ce
...
@@ -1458,6 +1458,8 @@ class CppClassType(CType):
...
@@ -1458,6 +1458,8 @@ class CppClassType(CType):
if
self
==
other_type
:
if
self
==
other_type
:
return
1
return
1
elif
self
.
template_type
==
other_type
.
template_type
:
elif
self
.
template_type
==
other_type
.
template_type
:
if
self
.
templates
==
other_type
.
templates
:
return
1
for
t1
,
t2
in
zip
(
self
.
templates
,
other_type
.
templates
):
for
t1
,
t2
in
zip
(
self
.
templates
,
other_type
.
templates
):
if
not
t1
.
same_as_resolved_type
(
t2
):
if
not
t1
.
same_as_resolved_type
(
t2
):
return
0
return
0
...
@@ -1770,14 +1772,27 @@ def best_match(args, functions, pos):
...
@@ -1770,14 +1772,27 @@ def best_match(args, functions, pos):
func_type
=
func
.
type
func_type
=
func
.
type
if
func_type
.
is_ptr
:
if
func_type
.
is_ptr
:
func_type
=
func_type
.
base_type
func_type
=
func_type
.
base_type
# Check function type
if
not
func_type
.
is_cfunction
:
if
not
func_type
.
is_error
:
error
(
pos
,
"Calling non-function type '%s'"
%
func_type
)
return
None
# Check no. of args
# Check no. of args
max_nargs
=
len
(
func_type
.
args
)
max_nargs
=
len
(
func_type
.
args
)
min_nargs
=
max_nargs
-
func_type
.
optional_arg_count
min_nargs
=
max_nargs
-
func_type
.
optional_arg_count
if
actual_nargs
<
min_nargs
\
if
actual_nargs
<
min_nargs
\
or
(
not
func_type
.
has_varargs
and
actual_nargs
>
max_nargs
):
or
(
not
func_type
.
has_varargs
and
actual_nargs
>
max_nargs
):
if
max_nargs
==
min_nargs
and
not
func_type
.
has_varargs
:
expectation
=
max_nargs
elif
actual_nargs
<
min_nargs
:
expectation
=
"at least %s"
%
min_nargs
else
:
expectation
=
"at most %s"
%
max_nargs
error_str
=
"Call with wrong number of arguments (expected %s, got %s)"
\
%
(
expectation
,
actual_nargs
)
continue
continue
score
=
[
0
,
0
,
0
]
score
=
[
0
,
0
,
0
]
for
i
in
range
(
len
(
args
)):
for
i
in
range
(
min
(
len
(
args
),
len
(
func_type
.
args
)
)):
src_type
=
args
[
i
].
type
src_type
=
args
[
i
].
type
dst_type
=
func_type
.
args
[
i
].
type
dst_type
=
func_type
.
args
[
i
].
type
if
dst_type
.
assignable_from
(
src_type
):
if
dst_type
.
assignable_from
(
src_type
):
...
@@ -1804,8 +1819,7 @@ def best_match(args, functions, pos):
...
@@ -1804,8 +1819,7 @@ def best_match(args, functions, pos):
# This will raise the right error.
# This will raise the right error.
return
func
return
func
else
:
else
:
error
(
pos
,
"Call with wrong number of arguments (expected %s, got %s)"
error
(
pos
,
error_str
)
%
(
expected_str
,
actual_nargs
))
return
None
return
None
...
...
Cython/Compiler/Symtab.py
View file @
c35599ce
...
@@ -301,25 +301,21 @@ class Scope(object):
...
@@ -301,25 +301,21 @@ class Scope(object):
# Create new entry, and add to dictionary if
# Create new entry, and add to dictionary if
# name is not None. Reports a warning if already
# name is not None. Reports a warning if already
# declared.
# declared.
if type.is_buffer and not isinstance(self, LocalScope):
error(pos, ERR_BUF_LOCALONLY)
if not self.in_cinclude and cname and re.match("
^
_
[
_A
-
Z
]
+
$
", cname):
if not self.in_cinclude and cname and re.match("
^
_
[
_A
-
Z
]
+
$
", cname):
# See http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html#Reserved-Names
# See http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html#Reserved-Names
warning(pos, "'%s'
is
a
reserved
name
in
C
.
" % cname, -1)
warning(pos, "'%s'
is
a
reserved
name
in
C
.
" % cname, -1)
entries = self.entries
entries = self.entries
overloaded = False
if name and name in entries:
if name and name in entries:
if visibility == 'extern':
if visibility == 'extern':
warning(pos, "'%s'
redeclared
" % name, 0)
warning(pos, "'%s'
redeclared
" % name, 0)
elif visibility != 'ignore':
elif visibility != 'ignore':
overloaded = True
error(pos, "'%s'
redeclared
" % name)
#error(pos, "'%s'
redeclared
" % name)
entry = Entry(name, cname, type, pos = pos)
entry = Entry(name, cname, type, pos = pos)
entry.in_cinclude = self.in_cinclude
entry.in_cinclude = self.in_cinclude
if name:
if name:
entry.qualified_name = self.qualify_name(name)
entry.qualified_name = self.qualify_name(name)
if overloaded:
entries[name].overloaded_alternatives.append(entry)
#print entries[name].overloaded_alternatives
else:
entries[name] = entry
entries[name] = entry
entry.scope = self
entry.scope = self
entry.visibility = visibility
entry.visibility = visibility
...
@@ -464,13 +460,14 @@ class Scope(object):
...
@@ -464,13 +460,14 @@ class Scope(object):
cname = self.mangle(Naming.func_prefix, name)
cname = self.mangle(Naming.func_prefix, name)
entry = self.lookup_here(name)
entry = self.lookup_here(name)
if entry:
if entry:
entry.overloaded_alternatives.append(self.add_cfunction(name, type, pos, cname, visibility, modifiers))
if visibility != 'private' and visibility != entry.visibility:
if visibility != 'private' and visibility != entry.visibility:
warning(pos, "
Function
'%s'
previously
declared
as
'%s'" % (name, entry.visibility), 1)
warning(pos, "
Function
'%s'
previously
declared
as
'%s'" % (name, entry.visibility), 1)
if not entry.type.same_as(type):
if not entry.type.same_as(type):
if visibility == 'extern' and entry.visibility == 'extern':
if visibility == 'extern' and entry.visibility == 'extern':
warning(pos, "
Function
signature
does
not
match
previous
declaration
", 1)
warning(pos, "
Function
signature
does
not
match
previous
declaration
", 1)
#entry.type = type
#entry.type = type
entry.overloaded_alternatives.append(
self.add_cfunction(name, type, pos, cname, visibility, modifiers))
else:
else:
error(pos, "
Function
signature
does
not
match
previous
declaration
")
error(pos, "
Function
signature
does
not
match
previous
declaration
")
else:
else:
...
@@ -1113,6 +1110,10 @@ class ModuleScope(Scope):
...
@@ -1113,6 +1110,10 @@ class ModuleScope(Scope):
#
#
return entry
return entry
def check_for_illegal_incomplete_ctypedef(self, typedef_flag, pos):
if typedef_flag and not self.in_cinclude:
error(pos, "Forward-referenced type must use '
cdef
', not '
ctypedef
'")
def declare_cpp_class(self, name, scope,
def declare_cpp_class(self, name, scope,
pos, cname = None, base_classes = [],
pos, cname = None, base_classes = [],
visibility = '
extern
', templates = None):
visibility = '
extern
', templates = None):
...
@@ -1626,6 +1627,11 @@ class CppClassScope(Scope):
...
@@ -1626,6 +1627,11 @@ class CppClassScope(Scope):
"C++ class member cannot be a Python object"
)
"C++ class member cannot be a Python object"
)
return
entry
return
entry
def
declare_cfunction
(
self
,
name
,
type
,
pos
,
cname
=
None
,
visibility
=
'extern'
,
defining
=
0
,
api
=
0
,
in_pxd
=
0
,
modifiers
=
()):
entry
=
self
.
declare_var
(
name
,
type
,
pos
,
cname
,
visibility
)
def
declare_inherited_cpp_attributes
(
self
,
base_scope
):
def
declare_inherited_cpp_attributes
(
self
,
base_scope
):
# Declare entries for all the C++ attributes of an
# Declare entries for all the C++ attributes of an
# inherited type, with cnames modified appropriately
# inherited type, with cnames modified appropriately
...
@@ -1638,7 +1644,7 @@ class CppClassScope(Scope):
...
@@ -1638,7 +1644,7 @@ class CppClassScope(Scope):
self
.
inherited_var_entries
.
append
(
entry
)
self
.
inherited_var_entries
.
append
(
entry
)
for
base_entry
in
base_scope
.
cfunc_entries
:
for
base_entry
in
base_scope
.
cfunc_entries
:
entry
=
self
.
declare_cfunction
(
base_entry
.
name
,
base_entry
.
type
,
entry
=
self
.
declare_cfunction
(
base_entry
.
name
,
base_entry
.
type
,
base_entry
.
pos
,
adapt
(
base_entry
.
cname
)
,
base_entry
.
pos
,
base_entry
.
cname
,
base_entry
.
visibility
,
base_entry
.
func_modifiers
)
base_entry
.
visibility
,
base_entry
.
func_modifiers
)
entry
.
is_inherited
=
1
entry
.
is_inherited
=
1
...
@@ -1699,3 +1705,7 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
...
@@ -1699,3 +1705,7 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
return NULL;
return NULL;
}
}
"""
)
"""
)
#------------------------------------------------------------------------------------
ERR_BUF_LOCALONLY
=
'Buffer types only allowed as function local variables'
tests/errors/e_bufaccess.pyx
View file @
c35599ce
...
@@ -12,8 +12,8 @@ def f():
...
@@ -12,8 +12,8 @@ def f():
cdef
object
[
int
,
2
,
well
]
buf6
cdef
object
[
int
,
2
,
well
]
buf6
_ERRORS
=
u"""
_ERRORS
=
u"""
1:1
1
: Buffer types only allowed as function local variables
1:1
7
: Buffer types only allowed as function local variables
3:
15
: Buffer types only allowed as function local variables
3:
21
: Buffer types only allowed as function local variables
6:27: "fakeoption" is not a buffer option
6:27: "fakeoption" is not a buffer option
"""
"""
#TODO:
#TODO:
...
...
tests/errors/e_del.pyx
View file @
c35599ce
...
@@ -13,8 +13,8 @@ def f(a):
...
@@ -13,8 +13,8 @@ def f(a):
del
s
.
m
# error: deletion of non-Python object
del
s
.
m
# error: deletion of non-Python object
_ERRORS
=
u"""
_ERRORS
=
u"""
8:6: Cannot assign to or delete this
8:6: Cannot assign to or delete this
9:45: Deletion of non-Python object
9:45: Deletion of non-Python
, non-C++
object
12:6: Deletion of non-Python object
12:6: Deletion of non-Python
, non-C++
object
13:6: Deletion of non-Python object
13:6: Deletion of non-Python
, non-C++
object
11:52: Deletion of local or C global name not supported
11:52: Deletion of local or C global name not supported
"""
"""
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment