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
Show 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 @@
...
@@ -2,7 +2,7 @@
cimport
cython
cimport
cython
cdef
class
UtilityCodeBase
(
object
):
cdef
class
UtilityCodeBase
(
object
):
pass
cdef
public
object
name
cdef
class
UtilityCode
(
UtilityCodeBase
):
cdef
class
UtilityCode
(
UtilityCodeBase
):
cdef
public
object
proto
cdef
public
object
proto
...
...
Cython/Compiler/Code.py
View file @
f0b5aafa
...
@@ -59,12 +59,8 @@ class UtilityCodeBase(object):
...
@@ -59,12 +59,8 @@ class UtilityCodeBase(object):
# @classmethod
# @classmethod
def
_add_utility
(
cls
,
utility
,
type
,
lines
,
begin_lineno
):
def
_add_utility
(
cls
,
utility
,
type
,
lines
,
begin_lineno
):
if
utility
:
if
utility
:
if
cls
.
is_cython_utility
:
# Remember line numbers as least until after templating
# Don't forget our line number
code
=
''
*
begin_lineno
+
''
.
join
(
lines
)
code
=
''
*
begin_lineno
+
''
.
join
(
lines
)
else
:
# line numbers are not important here
code
=
''
.
join
(
lines
)
if
type
==
'Proto'
:
if
type
==
'Proto'
:
utility
[
0
]
=
code
utility
[
0
]
=
code
...
@@ -96,7 +92,15 @@ class UtilityCodeBase(object):
...
@@ -96,7 +92,15 @@ class UtilityCodeBase(object):
f
=
Utils
.
open_source_file
(
filename
,
encoding
=
'UTF-8'
)
f
=
Utils
.
open_source_file
(
filename
,
encoding
=
'UTF-8'
)
try
:
try
:
for
lineno
,
line
in
enumerate
(
f
):
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
)
m
=
re
.
search
(
regex
,
line
)
if
m
:
if
m
:
cls
.
_add_utility
(
utility
,
type
,
lines
,
begin_lineno
)
cls
.
_add_utility
(
utility
,
type
,
lines
,
begin_lineno
)
...
@@ -115,8 +119,6 @@ class UtilityCodeBase(object):
...
@@ -115,8 +119,6 @@ class UtilityCodeBase(object):
lines
=
[]
lines
=
[]
else
:
else
:
lines
.
append
(
line
)
lines
.
append
(
line
)
finally
:
f
.
close
()
if
not
utility
:
if
not
utility
:
raise
ValueError
(
"Empty utility code file"
)
raise
ValueError
(
"Empty utility code file"
)
...
@@ -190,13 +192,20 @@ class UtilityCodeBase(object):
...
@@ -190,13 +192,20 @@ class UtilityCodeBase(object):
proto
,
impl
=
utilities
[
util_code_name
]
proto
,
impl
=
utilities
[
util_code_name
]
if
context
is
not
None
:
if
context
is
not
None
:
if
'__name'
not
in
context
:
context
[
'__name'
]
=
util_code_name
if
proto
:
if
proto
:
proto
=
tempita
.
sub
(
proto
,
**
context
)
proto
=
tempita
.
sub
(
proto
,
**
context
)
if
impl
:
if
impl
:
impl
=
tempita
.
sub
(
impl
,
**
context
)
impl
=
tempita
.
sub
(
impl
,
**
context
)
if
cls
.
is_cython_utility
:
# Remember line numbers
return
proto
,
impl
return
proto
,
impl
return
proto
and
proto
.
lstrip
(),
impl
and
impl
.
lstrip
()
load_as_string
=
classmethod
(
load_as_string
)
load_as_string
=
classmethod
(
load_as_string
)
def
__str__
(
self
):
def
__str__
(
self
):
...
...
Cython/Tempita/__init__.py
View file @
f0b5aafa
...
@@ -565,7 +565,7 @@ class TemplateDef(object):
...
@@ -565,7 +565,7 @@ class TemplateDef(object):
else:
else:
raise TypeError(
raise TypeError(
'
Extra
position
arguments
:
%
s
'
'
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():
for name, value_expr in defaults.iteritems():
if name not in values:
if name not in values:
values[name] = self._template._eval(
values[name] = self._template._eval(
...
@@ -660,6 +660,7 @@ def lex(s, name=None, trim_whitespace=True, line_offset=0, delimeters=None):
...
@@ -660,6 +660,7 @@ def lex(s, name=None, trim_whitespace=True, line_offset=0, delimeters=None):
chunks = []
chunks = []
last = 0
last = 0
last_pos = (1, 1)
last_pos = (1, 1)
token_re = re.compile(r'
%
s
|%
s
' % (re.escape(delimeters[0]),
token_re = re.compile(r'
%
s
|%
s
' % (re.escape(delimeters[0]),
re.escape(delimeters[1])))
re.escape(delimeters[1])))
for match in token_re.finditer(s):
for match in token_re.finditer(s):
...
...
Cython/Utils.py
View file @
f0b5aafa
...
@@ -130,6 +130,8 @@ class NormalisedNewlineStream(object):
...
@@ -130,6 +130,8 @@ class NormalisedNewlineStream(object):
while
data
:
while
data
:
content
.
append
(
data
)
content
.
append
(
data
)
data
=
self
.
read
(
0x1000
)
data
=
self
.
read
(
0x1000
)
# TODO: FIXME: Shouldn't this return lines with their newline appended??
return
u''
.
join
(
content
).
split
(
u'
\
n
'
)
return
u''
.
join
(
content
).
split
(
u'
\
n
'
)
io
=
None
io
=
None
...
...
tests/run/memslice_indexing.pyx
View file @
f0b5aafa
...
@@ -20,7 +20,7 @@ def create_array(shape, mode='c'):
...
@@ -20,7 +20,7 @@ def create_array(shape, mode='c'):
def
slice_contig_indexing
():
def
slice_contig_indexing
():
"""
"""
>>> print
"disabled"
>>> print
("disabled")
disabled
disabled
slice_contig_indexing()
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