Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
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
pyodide
Commits
ea75b225
Commit
ea75b225
authored
Nov 12, 2018
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor pythonexc2js
parent
a83e98b7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
46 deletions
+47
-46
src/python2js.c
src/python2js.c
+47
-46
No files found.
src/python2js.c
View file @
ea75b225
...
@@ -6,6 +6,11 @@
...
@@ -6,6 +6,11 @@
#include "jsproxy.h"
#include "jsproxy.h"
#include "pyproxy.h"
#include "pyproxy.h"
static
PyObject
*
tbmod
=
NULL
;
static
int
_python2js_unicode
(
PyObject
*
x
);
int
int
pythonexc2js
()
pythonexc2js
()
{
{
...
@@ -27,16 +32,20 @@ pythonexc2js()
...
@@ -27,16 +32,20 @@ pythonexc2js()
goto
exit
;
goto
exit
;
}
}
PyObject
*
tbmod
=
PyImport_ImportModule
(
"traceback"
);
if
(
tbmod
==
NULL
)
{
tbmod
=
PyImport_ImportModule
(
"traceback"
);
if
(
tbmod
==
NULL
)
{
if
(
tbmod
==
NULL
)
{
PyObject
*
repr
=
PyObject_Repr
(
value
);
PyObject
*
repr
=
PyObject_Repr
(
value
);
if
(
repr
==
NULL
)
{
if
(
repr
==
NULL
)
{
excval
=
hiwire_string_ascii
((
int
)
"Could not get repr for exception"
);
excval
=
hiwire_string_ascii
((
int
)
"Could not get repr for exception"
);
}
else
{
}
else
{
excval
=
python2js
(
repr
);
excval
=
_python2js_unicode
(
repr
);
Py_DECREF
(
repr
);
Py_DECREF
(
repr
);
}
}
}
else
{
goto
exit
;
}
}
PyObject
*
format_exception
;
PyObject
*
format_exception
;
if
(
traceback
==
NULL
||
traceback
==
Py_None
)
{
if
(
traceback
==
NULL
||
traceback
==
Py_None
)
{
no_traceback
=
1
;
no_traceback
=
1
;
...
@@ -63,29 +72,21 @@ pythonexc2js()
...
@@ -63,29 +72,21 @@ pythonexc2js()
PyErr_Clear
();
PyErr_Clear
();
goto
exit
;
goto
exit
;
}
else
{
}
else
{
PyObject
*
newline
=
PyUnicode_FromString
(
""
);
PyObject
*
empty
=
PyUnicode_FromString
(
""
);
PyObject
*
pystr
=
PyUnicode_Join
(
newline
,
pylines
);
PyObject
*
pystr
=
PyUnicode_Join
(
empty
,
pylines
);
printf
(
"Python exception:
\n
"
);
printf
(
"Python exception:
\n
"
);
printf
(
"%s
\n
"
,
PyUnicode_AsUTF8
(
pystr
));
printf
(
"%s
\n
"
,
PyUnicode_AsUTF8
(
pystr
));
excval
=
python2js
(
pystr
);
excval
=
_python2js_unicode
(
pystr
);
Py_DECREF
(
pystr
);
Py_DECREF
(
pystr
);
Py_DECREF
(
newline
);
Py_DECREF
(
empty
);
Py_DECREF
(
pylines
);
Py_DECREF
(
pylines
);
}
}
Py_DECREF
(
format_exception
);
Py_DECREF
(
format_exception
);
}
}
Py_DECREF
(
tbmod
);
}
exit:
exit:
Py_XDECREF
(
type
);
Py_XDECREF
(
value
);
Py_XDECREF
(
traceback
);
PyErr_Clear
();
PyErr_Clear
();
hiwire_throw_error
(
excval
);
hiwire_throw_error
(
excval
);
return
HW_ERROR
;
return
HW_ERROR
;
}
}
...
...
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