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
d4b42be1
Commit
d4b42be1
authored
Sep 09, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix error reporting in non-ASCII contexts for Py<=2.5
parent
e6103414
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
Cython/Compiler/Errors.py
Cython/Compiler/Errors.py
+22
-12
No files found.
Cython/Compiler/Errors.py
View file @
d4b42be1
...
@@ -28,6 +28,19 @@ def context(position):
...
@@ -28,6 +28,19 @@ def context(position):
s
=
u'%s
\
n
%s%s
\
n
'
%
(
u'-'
*
60
,
s
,
u'-'
*
60
)
s
=
u'%s
\
n
%s%s
\
n
'
%
(
u'-'
*
60
,
s
,
u'-'
*
60
)
return
s
return
s
def
format_position
(
position
):
if
position
:
return
u"%s:%d:%d: "
%
(
position
[
0
].
get_description
(),
position
[
1
],
position
[
2
])
return
u''
def
format_error
(
message
,
position
):
if
position
:
pos_str
=
format_position
(
position
)
cont
=
context
(
position
)
message
=
u'
\
n
Error converting Pyrex file to C:
\
n
%s
\
n
%s%s'
%
(
cont
,
pos_str
,
message
or
u''
)
return
message
class
CompileError
(
PyrexError
):
class
CompileError
(
PyrexError
):
def
__init__
(
self
,
position
=
None
,
message
=
u""
):
def
__init__
(
self
,
position
=
None
,
message
=
u""
):
...
@@ -36,12 +49,7 @@ class CompileError(PyrexError):
...
@@ -36,12 +49,7 @@ class CompileError(PyrexError):
self
.
reported
=
False
self
.
reported
=
False
# Deprecated and withdrawn in 2.6:
# Deprecated and withdrawn in 2.6:
# self.message = message
# self.message = message
if
position
:
Exception
.
__init__
(
self
,
format_error
(
message
,
position
))
pos_str
=
u"%s:%d:%d: "
%
(
position
[
0
].
get_description
(),
position
[
1
],
position
[
2
])
cont
=
context
(
position
)
message
=
u'
\
n
Error converting Pyrex file to C:
\
n
%s
\
n
%s%s'
%
(
cont
,
pos_str
,
message
)
Exception
.
__init__
(
self
,
message
)
class
CompileWarning
(
PyrexWarning
):
class
CompileWarning
(
PyrexWarning
):
...
@@ -49,17 +57,14 @@ class CompileWarning(PyrexWarning):
...
@@ -49,17 +57,14 @@ class CompileWarning(PyrexWarning):
self
.
position
=
position
self
.
position
=
position
# Deprecated and withdrawn in 2.6:
# Deprecated and withdrawn in 2.6:
# self.message = message
# self.message = message
if
position
:
Exception
.
__init__
(
self
,
format_position
(
position
)
+
message
)
pos_str
=
u"%s:%d:%d: "
%
(
position
[
0
].
get_description
(),
position
[
1
],
position
[
2
])
else
:
pos_str
=
u""
Exception
.
__init__
(
self
,
pos_str
+
message
)
class
InternalError
(
Exception
):
class
InternalError
(
Exception
):
# If this is ever raised, there is a bug in the compiler.
# If this is ever raised, there is a bug in the compiler.
def
__init__
(
self
,
message
):
def
__init__
(
self
,
message
):
self
.
message_only
=
message
Exception
.
__init__
(
self
,
u"Internal compiler error: %s"
Exception
.
__init__
(
self
,
u"Internal compiler error: %s"
%
message
)
%
message
)
...
@@ -71,6 +76,7 @@ class CompilerCrash(CompileError):
...
@@ -71,6 +76,7 @@ class CompilerCrash(CompileError):
message
=
u'
\
n
'
+
message
message
=
u'
\
n
'
+
message
else
:
else
:
message
=
u'
\
n
'
message
=
u'
\
n
'
self
.
message_only
=
message
if
context
:
if
context
:
message
=
u"Compiler crash in %s%s"
%
(
context
,
message
)
message
=
u"Compiler crash in %s%s"
%
(
context
,
message
)
if
stacktrace
:
if
stacktrace
:
...
@@ -117,7 +123,11 @@ def report_error(err):
...
@@ -117,7 +123,11 @@ def report_error(err):
# See Main.py for why dual reporting occurs. Quick fix for now.
# See Main.py for why dual reporting occurs. Quick fix for now.
if
err
.
reported
:
return
if
err
.
reported
:
return
err
.
reported
=
True
err
.
reported
=
True
line
=
u"%s
\
n
"
%
err
try
:
line
=
u"%s
\
n
"
%
err
except
UnicodeEncodeError
:
# Python <= 2.5 does this for non-ASCII Unicode exceptions
line
=
format_error
(
getattr
(
err
,
'message_only'
,
"[unprintable exception message]"
),
getattr
(
err
,
'position'
,
None
))
+
u'
\
n
'
if
listing_file
:
if
listing_file
:
try
:
listing_file
.
write
(
line
)
try
:
listing_file
.
write
(
line
)
except
UnicodeEncodeError
:
except
UnicodeEncodeError
:
...
...
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