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
Kirill Smelkov
cython
Commits
ab17365a
Commit
ab17365a
authored
May 12, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merged in latest cython-devel
parents
5c962c3b
f30c3a6b
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
281 additions
and
40 deletions
+281
-40
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+1
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+107
-39
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+3
-0
tests/run/specialfloat.pyx
tests/run/specialfloat.pyx
+9
-0
tests/run/strliterals.pyx
tests/run/strliterals.pyx
+5
-0
tests/run/unicode_indexing.pyx
tests/run/unicode_indexing.pyx
+156
-0
No files found.
Cython/Compiler/Code.py
View file @
ab17365a
...
...
@@ -289,7 +289,7 @@ class PyObjectConst(object):
possible_unicode_identifier
=
re
.
compile
(
ur"(?![0-9])\
w+$
", re.U).match
possible_bytes_identifier = re.compile(r"
(
?!
[
0
-
9
])
\
w
+
$
".encode('ASCII')).match
nice_identifier = re.compile(
'^[a-zA-Z0-9_]+$
').match
nice_identifier = re.compile(
r'
\
A[
a
-zA-Z0-9_]+
\
Z
'
).match
find_alphanums = re.compile('([a-zA-Z0-9]+)').findall
class StringConst(object):
...
...
Cython/Compiler/ExprNodes.py
View file @
ab17365a
This diff is collapsed.
Click to expand it.
Cython/Compiler/PyrexTypes.py
View file @
ab17365a
...
...
@@ -2443,6 +2443,9 @@ def spanning_type(type1, type2):
return
type1
elif
type1
is
py_object_type
or
type2
is
py_object_type
:
return
py_object_type
elif
type1
is
c_py_unicode_type
or
type2
is
c_py_unicode_type
:
# Py_UNICODE behaves more like a string than an int
return
py_object_type
span_type
=
_spanning_type
(
type1
,
type2
)
if
span_type
is
None
:
return
py_object_type
...
...
tests/run/specialfloat.pyx
View file @
ab17365a
DEF
FLOAT
=
12.5
DEF
EFLOAT
=
5e-1
DEF
FLOAT_NAN
=
float
(
'nan'
)
DEF
FLOAT_INFP
=
float
(
'+inf'
)
DEF
FLOAT_INFN
=
float
(
'-inf'
)
...
...
@@ -20,6 +21,14 @@ def f():
f
=
FLOAT
return
f
def
efloat
():
"""
>>> efloat()
0.5
"""
cdef
float
f
=
EFLOAT
return
f
def
nan1
():
"""
>>> nan1()
...
...
tests/run/strliterals.pyx
View file @
ab17365a
...
...
@@ -103,6 +103,9 @@ __doc__ = ur"""
True
>>> len(u6)
7
>>> newlines == "Aaa\n"
True
"""
import
sys
...
...
@@ -127,3 +130,5 @@ u3 = ur"abc\x11"
u4
=
Ur"abc\x11"
u5
=
uR"abc\x11"
u6
=
UR"abc\x11"
newlines
=
"Aaa
\
n
"
tests/run/unicode_indexing.pyx
0 → 100644
View file @
ab17365a
cimport
cython
cdef
unicode
_ustring
=
u'azerty123456'
ustring
=
_ustring
@
cython
.
test_assert_path_exists
(
"//CoerceToPyTypeNode"
,
"//IndexNode"
)
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
def
index
(
unicode
ustring
,
Py_ssize_t
i
):
"""
>>> index(ustring, 0)
u'a'
>>> index(ustring, 2)
u'e'
>>> index(ustring, -1)
u'6'
>>> index(ustring, -len(ustring))
u'a'
>>> index(ustring, len(ustring))
Traceback (most recent call last):
IndexError: string index out of range
"""
return
ustring
[
i
]
@
cython
.
test_assert_path_exists
(
"//CoerceToPyTypeNode"
,
"//IndexNode"
)
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
def
index_literal
(
Py_ssize_t
i
):
"""
>>> index_literal(0)
u'a'
>>> index_literal(2)
u'e'
>>> index_literal(-1)
u'6'
>>> index_literal(-len('azerty123456'))
u'a'
>>> index_literal(len(ustring))
Traceback (most recent call last):
IndexError: string index out of range
"""
return
u'azerty123456'
[
i
]
@
cython
.
test_assert_path_exists
(
"//CoerceToPyTypeNode"
,
"//IndexNode"
)
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
@
cython
.
boundscheck
(
False
)
def
index_no_boundscheck
(
unicode
ustring
,
Py_ssize_t
i
):
"""
>>> index_no_boundscheck(ustring, 0)
u'a'
>>> index_no_boundscheck(ustring, 2)
u'e'
>>> index_no_boundscheck(ustring, -1)
u'6'
>>> index_no_boundscheck(ustring, len(ustring)-1)
u'6'
>>> index_no_boundscheck(ustring, -len(ustring))
u'a'
"""
return
ustring
[
i
]
@
cython
.
test_assert_path_exists
(
"//CoerceToPyTypeNode"
,
"//IndexNode"
)
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
@
cython
.
boundscheck
(
False
)
def
unsigned_index_no_boundscheck
(
unicode
ustring
,
unsigned
int
i
):
"""
>>> unsigned_index_no_boundscheck(ustring, 0)
u'a'
>>> unsigned_index_no_boundscheck(ustring, 2)
u'e'
>>> unsigned_index_no_boundscheck(ustring, len(ustring)-1)
u'6'
"""
return
ustring
[
i
]
@
cython
.
test_assert_path_exists
(
"//CoerceToPyTypeNode"
,
"//IndexNode"
,
"//PrimaryCmpNode"
)
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
def
index_compare
(
unicode
ustring
,
Py_ssize_t
i
):
"""
>>> index_compare(ustring, 0)
True
>>> index_compare(ustring, 1)
False
>>> index_compare(ustring, -1)
False
>>> index_compare(ustring, -len(ustring))
True
>>> index_compare(ustring, len(ustring))
Traceback (most recent call last):
IndexError: string index out of range
"""
return
ustring
[
i
]
==
u'a'
@
cython
.
test_assert_path_exists
(
"//CoerceToPyTypeNode"
,
"//IndexNode"
,
"//PrimaryCmpNode"
)
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
def
index_compare_string
(
unicode
ustring
,
Py_ssize_t
i
,
unicode
other
):
"""
>>> index_compare_string(ustring, 0, ustring[0])
True
>>> index_compare_string(ustring, 0, ustring[:4])
False
>>> index_compare_string(ustring, 1, ustring[0])
False
>>> index_compare_string(ustring, 1, ustring[1])
True
>>> index_compare_string(ustring, -1, ustring[0])
False
>>> index_compare_string(ustring, -1, ustring[-1])
True
>>> index_compare_string(ustring, -len(ustring), ustring[-len(ustring)])
True
>>> index_compare_string(ustring, len(ustring), ustring)
Traceback (most recent call last):
IndexError: string index out of range
"""
return
ustring
[
i
]
==
other
@
cython
.
test_assert_path_exists
(
"//CoerceToPyTypeNode"
,
"//IndexNode"
,
"//MulNode"
,
"//MulNode/CoerceToPyTypeNode"
)
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
def
index_multiply
(
unicode
ustring
,
Py_ssize_t
i
,
int
mul
):
"""
>>> ustring[0] * 5
u'aaaaa'
>>> index_multiply(ustring, 0, 5)
u'aaaaa'
"""
return
ustring
[
i
]
*
mul
@
cython
.
test_assert_path_exists
(
"//CoerceToPyTypeNode"
,
"//IndexNode"
,
"//AddNode"
,
"//AddNode/CoerceToPyTypeNode"
)
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
def
index_add
(
unicode
ustring
,
Py_ssize_t
i
,
Py_ssize_t
j
):
"""
>>> ustring[0] + ustring[-1]
u'a6'
>>> index_add(ustring, 0, -1)
u'a6'
"""
return
ustring
[
i
]
+
ustring
[
j
]
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