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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
2269cde8
Commit
2269cde8
authored
May 15, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split some overly long code lines
parent
517a2774
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+17
-7
No files found.
Cython/Compiler/ExprNodes.py
View file @
2269cde8
...
@@ -1197,7 +1197,8 @@ class UnicodeNode(ConstNode):
...
@@ -1197,7 +1197,8 @@ class UnicodeNode(ConstNode):
# A Py_UNICODE* or unicode literal
# A Py_UNICODE* or unicode literal
#
#
# value EncodedString
# value EncodedString
# bytes_value BytesLiteral the literal parsed as bytes string ('-3' unicode literals only)
# bytes_value BytesLiteral the literal parsed as bytes string
# ('-3' unicode literals only)
is_string_literal
=
True
is_string_literal
=
True
bytes_value
=
None
bytes_value
=
None
...
@@ -1208,7 +1209,8 @@ class UnicodeNode(ConstNode):
...
@@ -1208,7 +1209,8 @@ class UnicodeNode(ConstNode):
def
as_sliced_node
(
self
,
start
,
stop
,
step
=
None
):
def
as_sliced_node
(
self
,
start
,
stop
,
step
=
None
):
if
StringEncoding
.
string_contains_surrogates
(
self
.
value
[:
stop
]):
if
StringEncoding
.
string_contains_surrogates
(
self
.
value
[:
stop
]):
# this is unsafe as it may give different results in different runtimes
# this is unsafe as it may give different results
# in different runtimes
return
None
return
None
value
=
StringEncoding
.
EncodedString
(
self
.
value
[
start
:
stop
:
step
])
value
=
StringEncoding
.
EncodedString
(
self
.
value
[
start
:
stop
:
step
])
value
.
encoding
=
self
.
value
.
encoding
value
.
encoding
=
self
.
value
.
encoding
...
@@ -1227,19 +1229,27 @@ class UnicodeNode(ConstNode):
...
@@ -1227,19 +1229,27 @@ class UnicodeNode(ConstNode):
pass
pass
elif
dst_type
.
is_unicode_char
:
elif
dst_type
.
is_unicode_char
:
if
not
self
.
can_coerce_to_char_literal
():
if
not
self
.
can_coerce_to_char_literal
():
error
(
self
.
pos
,
"Only single-character Unicode string literals or surrogate pairs can be coerced into Py_UCS4/Py_UNICODE."
)
error
(
self
.
pos
,
"Only single-character Unicode string literals or "
"surrogate pairs can be coerced into Py_UCS4/Py_UNICODE."
)
return
self
return
self
int_value
=
ord
(
self
.
value
)
int_value
=
ord
(
self
.
value
)
return
IntNode
(
self
.
pos
,
type
=
dst_type
,
value
=
str
(
int_value
),
constant_result
=
int_value
)
return
IntNode
(
self
.
pos
,
type
=
dst_type
,
value
=
str
(
int_value
),
constant_result
=
int_value
)
elif
not
dst_type
.
is_pyobject
:
elif
not
dst_type
.
is_pyobject
:
if
dst_type
.
is_string
and
self
.
bytes_value
is
not
None
:
if
dst_type
.
is_string
and
self
.
bytes_value
is
not
None
:
# special case: '-3' enforced unicode literal used in a C char* context
# special case: '-3' enforced unicode literal used in a
return
BytesNode
(
self
.
pos
,
value
=
self
.
bytes_value
).
coerce_to
(
dst_type
,
env
)
# C char* context
return
BytesNode
(
self
.
pos
,
value
=
self
.
bytes_value
).
coerce_to
(
dst_type
,
env
)
if
dst_type
.
is_pyunicode_ptr
:
if
dst_type
.
is_pyunicode_ptr
:
node
=
UnicodeNode
(
self
.
pos
,
value
=
self
.
value
)
node
=
UnicodeNode
(
self
.
pos
,
value
=
self
.
value
)
node
.
type
=
dst_type
node
.
type
=
dst_type
return
node
return
node
error
(
self
.
pos
,
"Unicode literals do not support coercion to C types other than Py_UNICODE/Py_UCS4 (for characters) or Py_UNICODE* (for strings)."
)
error
(
self
.
pos
,
"Unicode literals do not support coercion to C types other "
"than Py_UNICODE/Py_UCS4 (for characters) or Py_UNICODE* "
"(for strings)."
)
elif
dst_type
is
not
py_object_type
:
elif
dst_type
is
not
py_object_type
:
if
not
self
.
check_for_coercion_error
(
dst_type
,
env
):
if
not
self
.
check_for_coercion_error
(
dst_type
,
env
):
self
.
fail_assignment
(
dst_type
)
self
.
fail_assignment
(
dst_type
)
...
...
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