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
Boxiang Sun
cython
Commits
d1781ddc
Commit
d1781ddc
authored
Mar 20, 2011
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'upstream/master'
parents
231b6b64
63bcd561
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
90 additions
and
7 deletions
+90
-7
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+4
-1
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+11
-1
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+1
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+3
-3
Cython/Includes/libc/setjmp.pxd
Cython/Includes/libc/setjmp.pxd
+5
-0
runtests.py
runtests.py
+1
-1
tests/run/builtinnames.pyx
tests/run/builtinnames.pyx
+11
-0
tests/run/setjmp.pyx
tests/run/setjmp.pyx
+54
-0
No files found.
Cython/Build/Dependencies.py
View file @
d1781ddc
...
...
@@ -434,9 +434,12 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None):
for
key
,
value
in
base
.
values
.
items
():
if
key
not
in
kwds
:
kwds
[
key
]
=
value
sources
=
[
file
]
if
template
is
not
None
:
sources
+=
template
.
sources
[
1
:]
module_list
.
append
(
exn_type
(
name
=
module_name
,
sources
=
[
file
]
,
sources
=
sources
,
**
kwds
))
m
=
module_list
[
-
1
]
seen
.
add
(
name
)
...
...
Cython/Compiler/Code.py
View file @
d1781ddc
...
...
@@ -655,17 +655,27 @@ class GlobalState(object):
if self.should_declare(entry.cname, entry):
self.put_pyobject_decl(entry)
w = self.parts['cached_builtins']
conditional_name = False
if entry.name == 'xrange':
# replaced by range() in Py3
conditional_name = True
w.putln('#if PY_MAJOR_VERSION >= 3')
self.put_cached_builtin_init(
entry.pos, StringEncoding.EncodedString('range'),
entry.cname)
elif entry.name == 'BaseException':
# replace BaseException by Exception in Py<2.5
conditional_name = True
w.putln('#if PY_VERSION_HEX < 0x02050000')
self.put_cached_builtin_init(
entry.pos, StringEncoding.EncodedString('Exception'),
entry.cname)
if conditional_name:
w.putln('#else')
self.put_cached_builtin_init(
entry.pos, StringEncoding.EncodedString(entry.name),
entry.cname)
if
entry.name == 'xrange'
:
if
conditional_name
:
w.putln('#endif')
def put_cached_builtin_init(self, pos, name, cname):
...
...
Cython/Compiler/Parsing.py
View file @
d1781ddc
...
...
@@ -2011,7 +2011,7 @@ def looking_at_expr(s):
is_type
=
True
elif
s
.
sy
==
'*'
or
s
.
sy
==
'**'
:
s
.
next
()
is_type
=
s
.
sy
==
')'
is_type
=
s
.
sy
in
(
')'
,
']'
)
s
.
put_back
(
*
saved
)
elif
s
.
sy
==
'('
:
s
.
next
()
...
...
Cython/Compiler/Symtab.py
View file @
d1781ddc
...
...
@@ -902,8 +902,8 @@ class ModuleScope(Scope):
return self.outer_scope.lookup(name, language_level = self.context.language_level)
def declare_builtin(self, name, pos):
if not hasattr(builtins, name) and name
!= 'xrange'
:
# 'xrange'
is
special cased in Code.py
if not hasattr(builtins, name) and name
not in ('xrange', 'BaseException')
:
# 'xrange'
and 'BaseException' are
special cased in Code.py
if self.has_import_star:
entry = self.declare_var(name, py_object_type, pos)
return entry
...
...
@@ -1361,7 +1361,7 @@ class GeneratorExpressionScope(Scope):
self
.
genexp_prefix
=
"%s%d%s"
%
(
Naming
.
pyrex_prefix
,
len
(
name
),
name
)
def
mangle
(
self
,
prefix
,
name
):
return
'%s%s'
%
(
self
.
genexp_prefix
,
self
.
parent_scope
.
mangle
(
self
,
prefix
,
name
))
return
'%s%s'
%
(
self
.
genexp_prefix
,
self
.
parent_scope
.
mangle
(
prefix
,
name
))
def
declare_var
(
self
,
name
,
type
,
pos
,
cname
=
None
,
visibility
=
'private'
,
is_cdef
=
True
):
...
...
Cython/Includes/libc/setjmp.pxd
0 → 100644
View file @
d1781ddc
cdef
extern
from
"setjmp.h"
nogil
:
ctypedef
struct
jmp_buf
:
pass
int
setjmp
(
jmp_buf
STATE
)
void
longjmp
(
jmp_buf
STATE
,
int
VALUE
)
runtests.py
View file @
d1781ddc
...
...
@@ -894,7 +894,7 @@ class EmbedTest(unittest.TestCase):
# report the error for the original directory
libdir
=
sysconfig
.
get_config_var
(
'LIBDIR'
)
cython
=
'cython.py'
if
sys
.
version_info
[
0
]
>=
3
:
if
sys
.
version_info
[
0
]
>=
3
and
CY3_DIR
:
cython
=
os
.
path
.
join
(
CY3_DIR
,
cython
)
cython
=
os
.
path
.
abspath
(
os
.
path
.
join
(
'..'
,
'..'
,
cython
))
self
.
assert_
(
os
.
system
(
...
...
tests/run/builtinnames.pyx
View file @
d1781ddc
...
...
@@ -56,3 +56,14 @@ def test_for_in_range(arg):
for
c
in
range
(
arg
):
l
.
append
(
c
)
return
l
def
raise_and_catch_BaseException
():
"""
>>> raise_and_catch_BaseException()
1
"""
try
:
raise
BaseException
except
BaseException
:
return
1
return
2
tests/run/setjmp.pyx
0 → 100644
View file @
d1781ddc
from
libc.setjmp
cimport
*
cdef
void
check_nonzero
(
jmp_buf
ctx
,
int
x
)
nogil
:
if
x
==
0
:
longjmp
(
ctx
,
1
)
def
nonzero
(
int
x
):
"""
>>> nonzero(-1)
True
>>> nonzero(0)
False
>>> nonzero(1)
True
>>> nonzero(2)
True
"""
cdef
jmp_buf
ctx
if
setjmp
(
ctx
)
==
0
:
check_nonzero
(
ctx
,
x
)
return
True
else
:
return
False
from
libc.string
cimport
strcpy
cdef
char
error_msg
[
256
]
cdef
jmp_buf
error_ctx
cdef
void
error
(
char
msg
[])
nogil
:
strcpy
(
error_msg
,
msg
)
longjmp
(
error_ctx
,
1
)
cdef
void
c_call
(
int
x
)
nogil
:
if
x
<=
0
:
error
(
b"expected a positive value"
)
def
execute_c_call
(
int
x
):
"""
>>> execute_c_call(+2)
>>> execute_c_call(+1)
>>> execute_c_call(+0)
Traceback (most recent call last):
...
RuntimeError: expected a positive value
>>> execute_c_call(-1)
Traceback (most recent call last):
...
RuntimeError: expected a positive value
"""
if
not
setjmp
(
error_ctx
):
c_call
(
x
)
else
:
raise
RuntimeError
(
error_msg
.
decode
())
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