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
Gwenaël Samain
cython
Commits
02c0911f
Commit
02c0911f
authored
Sep 21, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle "-" sign in str_to_number() helper
parent
c36853a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
Cython/Utils.py
Cython/Utils.py
+10
-5
No files found.
Cython/Utils.py
View file @
02c0911f
...
...
@@ -292,17 +292,22 @@ def open_source_from_loader(loader,
def
str_to_number
(
value
):
# note: this expects a string as input that was accepted by the
# parser already
# parser already, with an optional "-" sign in front
is_neg
=
False
if
value
[:
1
]
==
'-'
:
is_neg
=
True
value
=
value
[
1
:]
if
len
(
value
)
<
2
:
value
=
int
(
value
,
0
)
elif
value
[
0
]
==
'0'
:
if
value
[
1
]
in
'xX'
:
literal_type
=
value
[
1
]
# 0'o' - 0'b' - 0'x'
if
literal_type
in
'xX'
:
# hex notation ('0x1AF')
value
=
int
(
value
[
2
:],
16
)
elif
value
[
1
]
in
'oO'
:
elif
literal_type
in
'oO'
:
# Py3 octal notation ('0o136')
value
=
int
(
value
[
2
:],
8
)
elif
value
[
1
]
in
'bB'
:
elif
literal_type
in
'bB'
:
# Py3 binary notation ('0b101')
value
=
int
(
value
[
2
:],
2
)
else
:
...
...
@@ -310,7 +315,7 @@ def str_to_number(value):
value
=
int
(
value
,
8
)
else
:
value
=
int
(
value
,
0
)
return
value
return
-
value
if
is_neg
else
value
def
long_literal
(
value
):
...
...
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