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
f0b5aafa
Commit
f0b5aafa
authored
Jul 23, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py23 compat
parent
73ed53c9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
29 deletions
+41
-29
Cython/Compiler/Code.pxd
Cython/Compiler/Code.pxd
+1
-1
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+35
-26
Cython/Tempita/__init__.py
Cython/Tempita/__init__.py
+2
-1
Cython/Utils.py
Cython/Utils.py
+2
-0
tests/run/memslice_indexing.pyx
tests/run/memslice_indexing.pyx
+1
-1
No files found.
Cython/Compiler/Code.pxd
View file @
f0b5aafa
...
...
@@ -2,7 +2,7 @@
cimport
cython
cdef
class
UtilityCodeBase
(
object
):
pass
cdef
public
object
name
cdef
class
UtilityCode
(
UtilityCodeBase
):
cdef
public
object
proto
...
...
Cython/Compiler/Code.py
View file @
f0b5aafa
...
...
@@ -59,12 +59,8 @@ class UtilityCodeBase(object):
# @classmethod
def
_add_utility
(
cls
,
utility
,
type
,
lines
,
begin_lineno
):
if
utility
:
if
cls
.
is_cython_utility
:
# Don't forget our line number
code
=
''
*
begin_lineno
+
''
.
join
(
lines
)
else
:
# line numbers are not important here
code
=
''
.
join
(
lines
)
# Remember line numbers as least until after templating
code
=
''
*
begin_lineno
+
''
.
join
(
lines
)
if
type
==
'Proto'
:
utility
[
0
]
=
code
...
...
@@ -96,28 +92,34 @@ class UtilityCodeBase(object):
f
=
Utils
.
open_source_file
(
filename
,
encoding
=
'UTF-8'
)
try
:
for
lineno
,
line
in
enumerate
(
f
):
m
=
re
.
search
(
regex
,
line
)
if
m
:
cls
.
_add_utility
(
utility
,
type
,
lines
,
begin_lineno
)
begin_lineno
=
lineno
+
1
name
=
m
.
group
(
1
)
if
name
.
endswith
(
".proto"
):
name
=
name
[:
-
6
]
type
=
'Proto'
else
:
type
=
'Code'
utility
=
utilities
.
setdefault
(
name
,
[
None
,
None
])
utilities
[
name
]
=
utility
lines
=
[]
else
:
lines
.
append
(
line
)
all_lines
=
f
.
readlines
()
# py23
finally
:
f
.
close
()
for
lineno
,
line
in
enumerate
(
all_lines
):
# apparently 'line' may be without trailing newline
# (NormalisedNewlineStream.readlines())
line
=
line
.
rstrip
()
+
'
\
n
'
m
=
re
.
search
(
regex
,
line
)
if
m
:
cls
.
_add_utility
(
utility
,
type
,
lines
,
begin_lineno
)
begin_lineno
=
lineno
+
1
name
=
m
.
group
(
1
)
if
name
.
endswith
(
".proto"
):
name
=
name
[:
-
6
]
type
=
'Proto'
else
:
type
=
'Code'
utility
=
utilities
.
setdefault
(
name
,
[
None
,
None
])
utilities
[
name
]
=
utility
lines
=
[]
else
:
lines
.
append
(
line
)
if
not
utility
:
raise
ValueError
(
"Empty utility code file"
)
...
...
@@ -190,12 +192,19 @@ class UtilityCodeBase(object):
proto
,
impl
=
utilities
[
util_code_name
]
if
context
is
not
None
:
if
'__name'
not
in
context
:
context
[
'__name'
]
=
util_code_name
if
proto
:
proto
=
tempita
.
sub
(
proto
,
**
context
)
if
impl
:
impl
=
tempita
.
sub
(
impl
,
**
context
)
return
proto
,
impl
if
cls
.
is_cython_utility
:
# Remember line numbers
return
proto
,
impl
return
proto
and
proto
.
lstrip
(),
impl
and
impl
.
lstrip
()
load_as_string
=
classmethod
(
load_as_string
)
...
...
Cython/Tempita/__init__.py
View file @
f0b5aafa
...
...
@@ -565,7 +565,7 @@ class TemplateDef(object):
else:
raise TypeError(
'
Extra
position
arguments
:
%
s
'
% '
,
'.join(
repr(v) for v in args
))
% '
,
'.join(
[repr(v) for v in args]
))
for name, value_expr in defaults.iteritems():
if name not in values:
values[name] = self._template._eval(
...
...
@@ -660,6 +660,7 @@ def lex(s, name=None, trim_whitespace=True, line_offset=0, delimeters=None):
chunks = []
last = 0
last_pos = (1, 1)
token_re = re.compile(r'
%
s
|%
s
' % (re.escape(delimeters[0]),
re.escape(delimeters[1])))
for match in token_re.finditer(s):
...
...
Cython/Utils.py
View file @
f0b5aafa
...
...
@@ -130,6 +130,8 @@ class NormalisedNewlineStream(object):
while
data
:
content
.
append
(
data
)
data
=
self
.
read
(
0x1000
)
# TODO: FIXME: Shouldn't this return lines with their newline appended??
return
u''
.
join
(
content
).
split
(
u'
\
n
'
)
io
=
None
...
...
tests/run/memslice_indexing.pyx
View file @
f0b5aafa
...
...
@@ -20,7 +20,7 @@ def create_array(shape, mode='c'):
def
slice_contig_indexing
():
"""
>>> print
"disabled"
>>> print
("disabled")
disabled
slice_contig_indexing()
...
...
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