1 import org.python.core.*;
3 public class traceback extends java.lang.Object {
4 static String[] jpy$mainProperties = new String[] {"python.modules.builtin", "exceptions:org.python.core.exceptions"};
5 static String[] jpy$proxyProperties = new String[] {"python.modules.builtin", "exceptions:org.python.core.exceptions", "python.options.showJavaExceptions", "true"};
6 static String[] jpy$packages = new String[] {"java.net", null, "java.lang", null, "org.python.core", null, "java.io", null, "java.util.zip", null};
8 public static class _PyInner extends PyFunctionTable implements PyRunnable {
9 private static PyObject s$0;
10 private static PyObject s$1;
11 private static PyObject s$2;
12 private static PyObject s$3;
13 private static PyObject s$4;
14 private static PyObject s$5;
15 private static PyObject s$6;
16 private static PyObject s$7;
17 private static PyObject s$8;
18 private static PyObject s$9;
19 private static PyObject s$10;
20 private static PyObject s$11;
21 private static PyObject s$12;
22 private static PyObject s$13;
23 private static PyObject s$14;
24 private static PyObject s$15;
25 private static PyObject s$16;
26 private static PyObject s$17;
27 private static PyObject s$18;
28 private static PyObject s$19;
29 private static PyObject s$20;
30 private static PyObject s$21;
31 private static PyObject s$22;
32 private static PyObject s$23;
33 private static PyObject i$24;
34 private static PyObject s$25;
35 private static PyObject i$26;
36 private static PyObject s$27;
37 private static PyObject s$28;
38 private static PyObject s$29;
39 private static PyObject s$30;
40 private static PyObject s$31;
41 private static PyObject s$32;
42 private static PyObject s$33;
43 private static PyObject s$34;
44 private static PyObject s$35;
45 private static PyObject s$36;
46 private static PyObject s$37;
47 private static PyObject s$38;
48 private static PyObject s$39;
49 private static PyObject s$40;
50 private static PyObject s$41;
51 private static PyObject s$42;
52 private static PyObject s$43;
53 private static PyObject i$44;
54 private static PyObject s$45;
55 private static PyObject s$46;
56 private static PyObject s$47;
57 private static PyObject s$48;
58 private static PyObject s$49;
59 private static PyFunctionTable funcTable;
60 private static PyCode c$0__print;
61 private static PyCode c$1_print_list;
62 private static PyCode c$2_format_list;
63 private static PyCode c$3_print_tb;
64 private static PyCode c$4_format_tb;
65 private static PyCode c$5_extract_tb;
66 private static PyCode c$6_print_exception;
67 private static PyCode c$7_format_exception;
68 private static PyCode c$8_format_exception_only;
69 private static PyCode c$9__some_str;
70 private static PyCode c$10_print_exc;
71 private static PyCode c$11_print_last;
72 private static PyCode c$12_print_stack;
73 private static PyCode c$13_format_stack;
74 private static PyCode c$14_extract_stack;
75 private static PyCode c$15_tb_lineno;
76 private static PyCode c$16_main;
77 private static void initConstants() {
78 s$0 = Py.newString("Extract, format and print information about Python stack traces.");
79 s$1 = Py.newString("extract_stack");
80 s$2 = Py.newString("extract_tb");
81 s$3 = Py.newString("format_exception");
82 s$4 = Py.newString("format_exception_only");
83 s$5 = Py.newString("format_list");
84 s$6 = Py.newString("format_stack");
85 s$7 = Py.newString("format_tb");
86 s$8 = Py.newString("print_exc");
87 s$9 = Py.newString("print_exception");
88 s$10 = Py.newString("print_last");
89 s$11 = Py.newString("print_stack");
90 s$12 = Py.newString("print_tb");
91 s$13 = Py.newString("tb_lineno");
92 s$14 = Py.newString("");
93 s$15 = Py.newString("\012");
94 s$16 = Py.newString("Print the list of tuples as returned by extract_tb() or\012 extract_stack() as a formatted stack trace to the given file.");
95 s$17 = Py.newString(" File \"%s\", line %d, in %s");
96 s$18 = Py.newString(" %s");
97 s$19 = Py.newString("Format a list of traceback entry tuples for printing.\012\012 Given a list of tuples as returned by extract_tb() or\012 extract_stack(), return a list of strings ready for printing.\012 Each string in the resulting list corresponds to the item with the\012 same index in the argument list. Each string ends in a newline;\012 the strings may contain internal newlines as well, for those items\012 whose source text line is not None.\012 ");
98 s$20 = Py.newString(" File \"%s\", line %d, in %s\012");
99 s$21 = Py.newString(" %s\012");
100 s$22 = Py.newString("Print up to 'limit' stack trace entries from the traceback 'tb'.\012\012 If 'limit' is omitted or None, all entries are printed. If 'file'\012 is omitted or None, the output goes to sys.stderr; otherwise\012 'file' should be an open file or file-like object with a write()\012 method.\012 ");
101 s$23 = Py.newString("tracebacklimit");
102 i$24 = Py.newInteger(0);
103 s$25 = Py.newString(" ");
104 i$26 = Py.newInteger(1);
105 s$27 = Py.newString("A shorthand for 'format_list(extract_stack(f, limit)).");
106 s$28 = Py.newString("Return list of up to limit pre-processed entries from traceback.\012\012 This is useful for alternate formatting of stack traces. If\012 'limit' is omitted or None, all entries are extracted. A\012 pre-processed stack trace entry is a quadruple (filename, line\012 number, function name, text) representing the information that is\012 usually printed for a stack trace. The text is a string with\012 leading and trailing whitespace stripped; if the source is not\012 available it is None.\012 ");
107 s$29 = Py.newString("Print exception up to 'limit' stack trace entries from 'tb' to 'file'.\012\012 This differs from print_tb() in the following ways: (1) if\012 traceback is not None, it prints a header \"Traceback (most recent\012 call last):\"; (2) it prints the exception type and value after the\012 stack trace; (3) if type is SyntaxError and value has the\012 appropriate format, it prints the line where the syntax error\012 occurred with a caret on the next line indicating the approximate\012 position of the error.\012 ");
108 s$30 = Py.newString("Traceback (most recent call last):");
109 s$31 = Py.newString(" ");
110 s$32 = Py.newString("Format a stack trace and the exception information.\012\012 The arguments have the same meaning as the corresponding arguments\012 to print_exception(). The return value is a list of strings, each\012 ending in a newline and some containing internal newlines. When\012 these lines are concatenated and printed, exactly the same text is\012 printed as does print_exception().\012 ");
111 s$33 = Py.newString("Traceback (most recent call last):\012");
112 s$34 = Py.newString("Format the exception part of a traceback.\012\012 The arguments are the exception type and value such as given by\012 sys.last_type and sys.last_value. The return value is a list of\012 strings, each ending in a newline. Normally, the list contains a\012 single string; however, for SyntaxError exceptions, it contains\012 several lines that (when printed) display detailed information\012 about where the syntax error occurred. The message indicating\012 which exception occurred is the always last string in the list.\012 ");
113 s$35 = Py.newString("<string>");
114 s$36 = Py.newString(" File \"%s\", line %d\012");
115 s$37 = Py.newString("%s^\012");
116 s$38 = Py.newString("%s: %s\012");
117 s$39 = Py.newString("%s\012");
118 s$40 = Py.newString("<unprintable %s object>");
119 s$41 = Py.newString("Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'.\012 (In fact, it uses sys.exc_info() to retrieve the same information\012 in a thread-safe way.)");
120 s$42 = Py.newString("This is a shorthand for 'print_exception(sys.last_type,\012 sys.last_value, sys.last_traceback, limit, file)'.");
121 s$43 = Py.newString("Print a stack trace from its invocation point.\012\012 The optional 'f' argument can be used to specify an alternate\012 stack frame at which to start. The optional 'limit' and 'file'\012 arguments have the same meaning as for print_exception().\012 ");
122 i$44 = Py.newInteger(2);
123 s$45 = Py.newString("Shorthand for 'format_list(extract_stack(f, limit))'.");
124 s$46 = Py.newString("Extract the raw traceback from the current stack frame.\012\012 The return value has the same format as for extract_tb(). The\012 optional 'f' and 'limit' arguments have the same meaning as for\012 print_stack(). Each item in the list is a quadruple (filename,\012 line number, function name, text), and the entries are in order\012 from oldest to newest stack frame.\012 ");
125 s$47 = Py.newString("Calculate correct line number of traceback given in tb.\012\012 Even works with -O on.\012 ");
126 s$48 = Py.newString("co_lnotab");
127 s$49 = Py.newString("/usr/share/jython/Lib-cpython/traceback.py");
128 funcTable = new _PyInner();
129 c$0__print = Py.newCode(3, new String[] {"file", "str", "terminator"}, "/usr/share/jython/Lib-cpython/traceback.py", "_print", false, false, funcTable, 0, null, null, 0, 1);
130 c$1_print_list = Py.newCode(2, new String[] {"extracted_list", "file", "line", "filename", "name", "lineno"}, "/usr/share/jython/Lib-cpython/traceback.py", "print_list", false, false, funcTable, 1, null, null, 0, 1);
131 c$2_format_list = Py.newCode(1, new String[] {"extracted_list", "line", "filename", "name", "item", "list", "lineno"}, "/usr/share/jython/Lib-cpython/traceback.py", "format_list", false, false, funcTable, 2, null, null, 0, 1);
132 c$3_print_tb = Py.newCode(3, new String[] {"tb", "limit", "file", "filename", "name", "lineno", "n", "f", "co", "line"}, "/usr/share/jython/Lib-cpython/traceback.py", "print_tb", false, false, funcTable, 3, null, null, 0, 1);
133 c$4_format_tb = Py.newCode(2, new String[] {"tb", "limit"}, "/usr/share/jython/Lib-cpython/traceback.py", "format_tb", false, false, funcTable, 4, null, null, 0, 1);
134 c$5_extract_tb = Py.newCode(2, new String[] {"tb", "limit", "filename", "name", "lineno", "n", "f", "list", "co", "line"}, "/usr/share/jython/Lib-cpython/traceback.py", "extract_tb", false, false, funcTable, 5, null, null, 0, 1);
135 c$6_print_exception = Py.newCode(5, new String[] {"etype", "value", "tb", "limit", "file", "line", "lines"}, "/usr/share/jython/Lib-cpython/traceback.py", "print_exception", false, false, funcTable, 6, null, null, 0, 1);
136 c$7_format_exception = Py.newCode(4, new String[] {"etype", "value", "tb", "limit", "list"}, "/usr/share/jython/Lib-cpython/traceback.py", "format_exception", false, false, funcTable, 7, null, null, 0, 1);
137 c$8_format_exception_only = Py.newCode(2, new String[] {"etype", "value", "stype", "msg", "offset", "lineno", "line", "s", "filename", "i", "list", "c"}, "/usr/share/jython/Lib-cpython/traceback.py", "format_exception_only", false, false, funcTable, 8, null, null, 0, 1);
138 c$9__some_str = Py.newCode(1, new String[] {"value"}, "/usr/share/jython/Lib-cpython/traceback.py", "_some_str", false, false, funcTable, 9, null, null, 0, 1);
139 c$10_print_exc = Py.newCode(2, new String[] {"limit", "file", "tb", "etype", "value"}, "/usr/share/jython/Lib-cpython/traceback.py", "print_exc", false, false, funcTable, 10, null, null, 0, 1);
140 c$11_print_last = Py.newCode(2, new String[] {"limit", "file"}, "/usr/share/jython/Lib-cpython/traceback.py", "print_last", false, false, funcTable, 11, null, null, 0, 1);
141 c$12_print_stack = Py.newCode(3, new String[] {"f", "limit", "file"}, "/usr/share/jython/Lib-cpython/traceback.py", "print_stack", false, false, funcTable, 12, null, null, 0, 1);
142 c$13_format_stack = Py.newCode(2, new String[] {"f", "limit"}, "/usr/share/jython/Lib-cpython/traceback.py", "format_stack", false, false, funcTable, 13, null, null, 0, 1);
143 c$14_extract_stack = Py.newCode(2, new String[] {"f", "limit", "filename", "name", "lineno", "n", "list", "co", "line"}, "/usr/share/jython/Lib-cpython/traceback.py", "extract_stack", false, false, funcTable, 14, null, null, 0, 1);
144 c$15_tb_lineno = Py.newCode(1, new String[] {"tb", "tab", "i", "c", "addr", "stopat", "line"}, "/usr/share/jython/Lib-cpython/traceback.py", "tb_lineno", false, false, funcTable, 15, null, null, 0, 1);
145 c$16_main = Py.newCode(0, new String[] {}, "/usr/share/jython/Lib-cpython/traceback.py", "main", false, false, funcTable, 16, null, null, 0, 0);
149 public PyCode getMain() {
150 if (c$16_main == null) _PyInner.initConstants();
154 public PyObject call_function(int index, PyFrame frame) {
157 return _PyInner._print$1(frame);
159 return _PyInner.print_list$2(frame);
161 return _PyInner.format_list$3(frame);
163 return _PyInner.print_tb$4(frame);
165 return _PyInner.format_tb$5(frame);
167 return _PyInner.extract_tb$6(frame);
169 return _PyInner.print_exception$7(frame);
171 return _PyInner.format_exception$8(frame);
173 return _PyInner.format_exception_only$9(frame);
175 return _PyInner._some_str$10(frame);
177 return _PyInner.print_exc$11(frame);
179 return _PyInner.print_last$12(frame);
181 return _PyInner.print_stack$13(frame);
183 return _PyInner.format_stack$14(frame);
185 return _PyInner.extract_stack$15(frame);
187 return _PyInner.tb_lineno$16(frame);
189 return _PyInner.main$17(frame);
195 private static PyObject _print$1(PyFrame frame) {
196 frame.getlocal(0).invoke("write", frame.getlocal(1)._add(frame.getlocal(2)));
200 private static PyObject print_list$2(PyFrame frame) {
201 // Temporary Variables
203 PyObject[] t$0$PyObject__;
204 PyObject t$0$PyObject, t$1$PyObject;
207 /* Print the list of tuples as returned by extract_tb() or
208 extract_stack() as a formatted stack trace to the given file. */
209 if (frame.getlocal(1).__not__().__nonzero__()) {
210 frame.setlocal(1, frame.getglobal("sys").__getattr__("stderr"));
213 t$1$PyObject = frame.getlocal(0);
214 while ((t$0$PyObject = t$1$PyObject.__finditem__(t$0$int++)) != null) {
215 t$0$PyObject__ = org.python.core.Py.unpackSequence(t$0$PyObject, 4);
216 frame.setlocal(3, t$0$PyObject__[0]);
217 frame.setlocal(5, t$0$PyObject__[1]);
218 frame.setlocal(4, t$0$PyObject__[2]);
219 frame.setlocal(2, t$0$PyObject__[3]);
220 frame.getglobal("_print").__call__(frame.getlocal(1), s$17._mod(new PyTuple(new PyObject[] {frame.getlocal(3), frame.getlocal(5), frame.getlocal(4)})));
221 if (frame.getlocal(2).__nonzero__()) {
222 frame.getglobal("_print").__call__(frame.getlocal(1), s$18._mod(frame.getlocal(2).invoke("strip")));
228 private static PyObject format_list$3(PyFrame frame) {
229 // Temporary Variables
231 PyObject[] t$0$PyObject__;
232 PyObject t$0$PyObject, t$1$PyObject;
235 /* Format a list of traceback entry tuples for printing.
237 Given a list of tuples as returned by extract_tb() or
238 extract_stack(), return a list of strings ready for printing.
239 Each string in the resulting list corresponds to the item with the
240 same index in the argument list. Each string ends in a newline;
241 the strings may contain internal newlines as well, for those items
242 whose source text line is not None.
244 frame.setlocal(5, new PyList(new PyObject[] {}));
246 t$1$PyObject = frame.getlocal(0);
247 while ((t$0$PyObject = t$1$PyObject.__finditem__(t$0$int++)) != null) {
248 t$0$PyObject__ = org.python.core.Py.unpackSequence(t$0$PyObject, 4);
249 frame.setlocal(2, t$0$PyObject__[0]);
250 frame.setlocal(6, t$0$PyObject__[1]);
251 frame.setlocal(3, t$0$PyObject__[2]);
252 frame.setlocal(1, t$0$PyObject__[3]);
253 frame.setlocal(4, s$20._mod(new PyTuple(new PyObject[] {frame.getlocal(2), frame.getlocal(6), frame.getlocal(3)})));
254 if (frame.getlocal(1).__nonzero__()) {
255 frame.setlocal(4, frame.getlocal(4)._add(s$21._mod(frame.getlocal(1).invoke("strip"))));
257 frame.getlocal(5).invoke("append", frame.getlocal(4));
259 return frame.getlocal(5);
262 private static PyObject print_tb$4(PyFrame frame) {
263 // Temporary Variables
264 PyObject t$0$PyObject, t$1$PyObject;
267 /* Print up to 'limit' stack trace entries from the traceback 'tb'.
269 If 'limit' is omitted or None, all entries are printed. If 'file'
270 is omitted or None, the output goes to sys.stderr; otherwise
271 'file' should be an open file or file-like object with a write()
274 if (frame.getlocal(2).__not__().__nonzero__()) {
275 frame.setlocal(2, frame.getglobal("sys").__getattr__("stderr"));
277 if (frame.getlocal(1)._is(frame.getglobal("None")).__nonzero__()) {
278 if (frame.getglobal("hasattr").__call__(frame.getglobal("sys"), s$23).__nonzero__()) {
279 frame.setlocal(1, frame.getglobal("sys").__getattr__("tracebacklimit"));
282 frame.setlocal(6, i$24);
283 while (((t$0$PyObject = frame.getlocal(0)._isnot(frame.getglobal("None"))).__nonzero__() ? ((t$1$PyObject = frame.getlocal(1)._is(frame.getglobal("None"))).__nonzero__() ? t$1$PyObject : frame.getlocal(6)._lt(frame.getlocal(1))) : t$0$PyObject).__nonzero__()) {
284 frame.setlocal(7, frame.getlocal(0).__getattr__("tb_frame"));
285 frame.setlocal(5, frame.getglobal("tb_lineno").__call__(frame.getlocal(0)));
286 frame.setlocal(8, frame.getlocal(7).__getattr__("f_code"));
287 frame.setlocal(3, frame.getlocal(8).__getattr__("co_filename"));
288 frame.setlocal(4, frame.getlocal(8).__getattr__("co_name"));
289 frame.getglobal("_print").__call__(frame.getlocal(2), s$17._mod(new PyTuple(new PyObject[] {frame.getlocal(3), frame.getlocal(5), frame.getlocal(4)})));
290 frame.setlocal(9, frame.getglobal("linecache").__getattr__("getline").__call__(frame.getlocal(3), frame.getlocal(5)));
291 if (frame.getlocal(9).__nonzero__()) {
292 frame.getglobal("_print").__call__(frame.getlocal(2), s$25._add(frame.getlocal(9).invoke("strip")));
294 frame.setlocal(0, frame.getlocal(0).__getattr__("tb_next"));
295 frame.setlocal(6, frame.getlocal(6)._add(i$26));
300 private static PyObject format_tb$5(PyFrame frame) {
301 /* A shorthand for 'format_list(extract_stack(f, limit)). */
302 return frame.getglobal("format_list").__call__(frame.getglobal("extract_tb").__call__(frame.getlocal(0), frame.getlocal(1)));
305 private static PyObject extract_tb$6(PyFrame frame) {
306 // Temporary Variables
307 PyObject t$0$PyObject, t$1$PyObject;
310 /* Return list of up to limit pre-processed entries from traceback.
312 This is useful for alternate formatting of stack traces. If
313 'limit' is omitted or None, all entries are extracted. A
314 pre-processed stack trace entry is a quadruple (filename, line
315 number, function name, text) representing the information that is
316 usually printed for a stack trace. The text is a string with
317 leading and trailing whitespace stripped; if the source is not
318 available it is None.
320 if (frame.getlocal(1)._is(frame.getglobal("None")).__nonzero__()) {
321 if (frame.getglobal("hasattr").__call__(frame.getglobal("sys"), s$23).__nonzero__()) {
322 frame.setlocal(1, frame.getglobal("sys").__getattr__("tracebacklimit"));
325 frame.setlocal(7, new PyList(new PyObject[] {}));
326 frame.setlocal(5, i$24);
327 while (((t$0$PyObject = frame.getlocal(0)._isnot(frame.getglobal("None"))).__nonzero__() ? ((t$1$PyObject = frame.getlocal(1)._is(frame.getglobal("None"))).__nonzero__() ? t$1$PyObject : frame.getlocal(5)._lt(frame.getlocal(1))) : t$0$PyObject).__nonzero__()) {
328 frame.setlocal(6, frame.getlocal(0).__getattr__("tb_frame"));
329 frame.setlocal(4, frame.getglobal("tb_lineno").__call__(frame.getlocal(0)));
330 frame.setlocal(8, frame.getlocal(6).__getattr__("f_code"));
331 frame.setlocal(2, frame.getlocal(8).__getattr__("co_filename"));
332 frame.setlocal(3, frame.getlocal(8).__getattr__("co_name"));
333 frame.setlocal(9, frame.getglobal("linecache").__getattr__("getline").__call__(frame.getlocal(2), frame.getlocal(4)));
334 if (frame.getlocal(9).__nonzero__()) {
335 frame.setlocal(9, frame.getlocal(9).invoke("strip"));
338 frame.setlocal(9, frame.getglobal("None"));
340 frame.getlocal(7).invoke("append", new PyTuple(new PyObject[] {frame.getlocal(2), frame.getlocal(4), frame.getlocal(3), frame.getlocal(9)}));
341 frame.setlocal(0, frame.getlocal(0).__getattr__("tb_next"));
342 frame.setlocal(5, frame.getlocal(5)._add(i$26));
344 return frame.getlocal(7);
347 private static PyObject print_exception$7(PyFrame frame) {
348 // Temporary Variables
350 PyObject t$0$PyObject, t$1$PyObject;
353 /* Print exception up to 'limit' stack trace entries from 'tb' to 'file'.
355 This differs from print_tb() in the following ways: (1) if
356 traceback is not None, it prints a header "Traceback (most recent
357 call last):"; (2) it prints the exception type and value after the
358 stack trace; (3) if type is SyntaxError and value has the
359 appropriate format, it prints the line where the syntax error
360 occurred with a caret on the next line indicating the approximate
361 position of the error.
363 if (frame.getlocal(4).__not__().__nonzero__()) {
364 frame.setlocal(4, frame.getglobal("sys").__getattr__("stderr"));
366 if (frame.getlocal(2).__nonzero__()) {
367 frame.getglobal("_print").__call__(frame.getlocal(4), s$30);
368 frame.getglobal("print_tb").__call__(frame.getlocal(2), frame.getlocal(3), frame.getlocal(4));
370 frame.setlocal(6, frame.getglobal("format_exception_only").__call__(frame.getlocal(0), frame.getlocal(1)));
372 t$1$PyObject = frame.getlocal(6).__getslice__(null, i$26.__neg__(), null);
373 while ((t$0$PyObject = t$1$PyObject.__finditem__(t$0$int++)) != null) {
374 frame.setlocal(5, t$0$PyObject);
375 frame.getglobal("_print").__call__(frame.getlocal(4), frame.getlocal(5), s$31);
377 frame.getglobal("_print").__call__(frame.getlocal(4), frame.getlocal(6).__getitem__(i$26.__neg__()), s$14);
381 private static PyObject format_exception$8(PyFrame frame) {
382 /* Format a stack trace and the exception information.
384 The arguments have the same meaning as the corresponding arguments
385 to print_exception(). The return value is a list of strings, each
386 ending in a newline and some containing internal newlines. When
387 these lines are concatenated and printed, exactly the same text is
388 printed as does print_exception().
390 if (frame.getlocal(2).__nonzero__()) {
391 frame.setlocal(4, new PyList(new PyObject[] {s$33}));
392 frame.setlocal(4, frame.getlocal(4)._add(frame.getglobal("format_tb").__call__(frame.getlocal(2), frame.getlocal(3))));
395 frame.setlocal(4, new PyList(new PyObject[] {}));
397 frame.setlocal(4, frame.getlocal(4)._add(frame.getglobal("format_exception_only").__call__(frame.getlocal(0), frame.getlocal(1))));
398 return frame.getlocal(4);
401 private static PyObject format_exception_only$9(PyFrame frame) {
402 // Temporary Variables
404 PyObject[] t$0$PyObject__, t$1$PyObject__;
406 PyObject t$0$PyObject, t$1$PyObject;
407 PyException t$0$PyException;
410 /* Format the exception part of a traceback.
412 The arguments are the exception type and value such as given by
413 sys.last_type and sys.last_value. The return value is a list of
414 strings, each ending in a newline. Normally, the list contains a
415 single string; however, for SyntaxError exceptions, it contains
416 several lines that (when printed) display detailed information
417 about where the syntax error occurred. The message indicating
418 which exception occurred is the always last string in the list.
420 frame.setlocal(10, new PyList(new PyObject[] {}));
421 if (frame.getglobal("type").__call__(frame.getlocal(0))._eq(frame.getglobal("types").__getattr__("ClassType")).__nonzero__()) {
422 frame.setlocal(2, frame.getlocal(0).__getattr__("__name__"));
425 frame.setlocal(2, frame.getlocal(0));
427 if (frame.getlocal(1)._is(frame.getglobal("None")).__nonzero__()) {
428 frame.getlocal(10).invoke("append", frame.getglobal("str").__call__(frame.getlocal(2))._add(s$15));
431 if (frame.getlocal(0)._is(frame.getglobal("SyntaxError")).__nonzero__()) {
434 t$0$PyObject__ = org.python.core.Py.unpackSequence(frame.getlocal(1), 2);
435 frame.setlocal(3, t$0$PyObject__[0]);
436 t$1$PyObject__ = org.python.core.Py.unpackSequence(t$0$PyObject__[1], 4);
437 frame.setlocal(8, t$1$PyObject__[0]);
438 frame.setlocal(5, t$1$PyObject__[1]);
439 frame.setlocal(4, t$1$PyObject__[2]);
440 frame.setlocal(6, t$1$PyObject__[3]);
442 catch (Throwable x$0) {
444 t$0$PyException = Py.setException(x$0, frame);
448 if (frame.getlocal(8).__not__().__nonzero__()) {
449 frame.setlocal(8, s$35);
451 frame.getlocal(10).invoke("append", s$36._mod(new PyTuple(new PyObject[] {frame.getlocal(8), frame.getlocal(5)})));
452 if (frame.getlocal(6)._isnot(frame.getglobal("None")).__nonzero__()) {
453 frame.setlocal(9, i$24);
454 while (((t$0$PyObject = frame.getlocal(9)._lt(frame.getglobal("len").__call__(frame.getlocal(6)))).__nonzero__() ? frame.getlocal(6).__getitem__(frame.getlocal(9)).invoke("isspace") : t$0$PyObject).__nonzero__()) {
455 frame.setlocal(9, frame.getlocal(9)._add(i$26));
457 frame.getlocal(10).invoke("append", s$21._mod(frame.getlocal(6).invoke("strip")));
458 if (frame.getlocal(4)._isnot(frame.getglobal("None")).__nonzero__()) {
459 frame.setlocal(7, s$25);
461 t$1$PyObject = frame.getlocal(6).__getslice__(frame.getlocal(9), frame.getlocal(4)._sub(i$26), null);
462 while ((t$0$PyObject = t$1$PyObject.__finditem__(t$0$int++)) != null) {
463 frame.setlocal(11, t$0$PyObject);
464 if (frame.getlocal(11).invoke("isspace").__nonzero__()) {
465 frame.setlocal(7, frame.getlocal(7)._add(frame.getlocal(11)));
468 frame.setlocal(7, frame.getlocal(7)._add(s$31));
471 frame.getlocal(10).invoke("append", s$37._mod(frame.getlocal(7)));
473 frame.setlocal(1, frame.getlocal(3));
477 frame.setlocal(7, frame.getglobal("_some_str").__call__(frame.getlocal(1)));
478 if (frame.getlocal(7).__nonzero__()) {
479 frame.getlocal(10).invoke("append", s$38._mod(new PyTuple(new PyObject[] {frame.getglobal("str").__call__(frame.getlocal(2)), frame.getlocal(7)})));
482 frame.getlocal(10).invoke("append", s$39._mod(frame.getglobal("str").__call__(frame.getlocal(2))));
485 return frame.getlocal(10);
488 private static PyObject _some_str$10(PyFrame frame) {
489 // Temporary Variables
490 PyException t$0$PyException;
494 return frame.getglobal("str").__call__(frame.getlocal(0));
496 catch (Throwable x$0) {
497 t$0$PyException = Py.setException(x$0, frame);
498 return s$40._mod(frame.getglobal("type").__call__(frame.getlocal(0)).__getattr__("__name__"));
502 private static PyObject print_exc$11(PyFrame frame) {
503 // Temporary Variables
504 PyObject[] t$0$PyObject__;
505 PyObject t$0$PyObject;
508 /* Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'.
509 (In fact, it uses sys.exc_info() to retrieve the same information
510 in a thread-safe way.) */
511 if (frame.getlocal(1).__not__().__nonzero__()) {
512 frame.setlocal(1, frame.getglobal("sys").__getattr__("stderr"));
515 t$0$PyObject__ = org.python.core.Py.unpackSequence(frame.getglobal("sys").__getattr__("exc_info").__call__(), 3);
516 frame.setlocal(3, t$0$PyObject__[0]);
517 frame.setlocal(4, t$0$PyObject__[1]);
518 frame.setlocal(2, t$0$PyObject__[2]);
519 frame.getglobal("print_exception").__call__(new PyObject[] {frame.getlocal(3), frame.getlocal(4), frame.getlocal(2), frame.getlocal(0), frame.getlocal(1)});
522 t$0$PyObject = frame.getglobal("None");
523 frame.setlocal(3, t$0$PyObject);
524 frame.setlocal(4, t$0$PyObject);
525 frame.setlocal(2, t$0$PyObject);
530 private static PyObject print_last$12(PyFrame frame) {
531 /* This is a shorthand for 'print_exception(sys.last_type,
532 sys.last_value, sys.last_traceback, limit, file)'. */
533 if (frame.getlocal(1).__not__().__nonzero__()) {
534 frame.setlocal(1, frame.getglobal("sys").__getattr__("stderr"));
536 frame.getglobal("print_exception").__call__(new PyObject[] {frame.getglobal("sys").__getattr__("last_type"), frame.getglobal("sys").__getattr__("last_value"), frame.getglobal("sys").__getattr__("last_traceback"), frame.getlocal(0), frame.getlocal(1)});
540 private static PyObject print_stack$13(PyFrame frame) {
541 // Temporary Variables
542 PyException t$0$PyException;
545 /* Print a stack trace from its invocation point.
547 The optional 'f' argument can be used to specify an alternate
548 stack frame at which to start. The optional 'limit' and 'file'
549 arguments have the same meaning as for print_exception().
551 if (frame.getlocal(0)._is(frame.getglobal("None")).__nonzero__()) {
553 throw Py.makeException(frame.getglobal("ZeroDivisionError"));
555 catch (Throwable x$0) {
556 t$0$PyException = Py.setException(x$0, frame);
557 if (Py.matchException(t$0$PyException, frame.getglobal("ZeroDivisionError"))) {
558 frame.setlocal(0, frame.getglobal("sys").__getattr__("exc_info").__call__().__getitem__(i$44).__getattr__("tb_frame").__getattr__("f_back"));
560 else throw t$0$PyException;
563 frame.getglobal("print_list").__call__(frame.getglobal("extract_stack").__call__(frame.getlocal(0), frame.getlocal(1)), frame.getlocal(2));
567 private static PyObject format_stack$14(PyFrame frame) {
568 // Temporary Variables
569 PyException t$0$PyException;
572 /* Shorthand for 'format_list(extract_stack(f, limit))'. */
573 if (frame.getlocal(0)._is(frame.getglobal("None")).__nonzero__()) {
575 throw Py.makeException(frame.getglobal("ZeroDivisionError"));
577 catch (Throwable x$0) {
578 t$0$PyException = Py.setException(x$0, frame);
579 if (Py.matchException(t$0$PyException, frame.getglobal("ZeroDivisionError"))) {
580 frame.setlocal(0, frame.getglobal("sys").__getattr__("exc_info").__call__().__getitem__(i$44).__getattr__("tb_frame").__getattr__("f_back"));
582 else throw t$0$PyException;
585 return frame.getglobal("format_list").__call__(frame.getglobal("extract_stack").__call__(frame.getlocal(0), frame.getlocal(1)));
588 private static PyObject extract_stack$15(PyFrame frame) {
589 // Temporary Variables
590 PyObject t$0$PyObject, t$1$PyObject;
591 PyException t$0$PyException;
594 /* Extract the raw traceback from the current stack frame.
596 The return value has the same format as for extract_tb(). The
597 optional 'f' and 'limit' arguments have the same meaning as for
598 print_stack(). Each item in the list is a quadruple (filename,
599 line number, function name, text), and the entries are in order
600 from oldest to newest stack frame.
602 if (frame.getlocal(0)._is(frame.getglobal("None")).__nonzero__()) {
604 throw Py.makeException(frame.getglobal("ZeroDivisionError"));
606 catch (Throwable x$0) {
607 t$0$PyException = Py.setException(x$0, frame);
608 if (Py.matchException(t$0$PyException, frame.getglobal("ZeroDivisionError"))) {
609 frame.setlocal(0, frame.getglobal("sys").__getattr__("exc_info").__call__().__getitem__(i$44).__getattr__("tb_frame").__getattr__("f_back"));
611 else throw t$0$PyException;
614 if (frame.getlocal(1)._is(frame.getglobal("None")).__nonzero__()) {
615 if (frame.getglobal("hasattr").__call__(frame.getglobal("sys"), s$23).__nonzero__()) {
616 frame.setlocal(1, frame.getglobal("sys").__getattr__("tracebacklimit"));
619 frame.setlocal(6, new PyList(new PyObject[] {}));
620 frame.setlocal(5, i$24);
621 while (((t$0$PyObject = frame.getlocal(0)._isnot(frame.getglobal("None"))).__nonzero__() ? ((t$1$PyObject = frame.getlocal(1)._is(frame.getglobal("None"))).__nonzero__() ? t$1$PyObject : frame.getlocal(5)._lt(frame.getlocal(1))) : t$0$PyObject).__nonzero__()) {
622 frame.setlocal(4, frame.getlocal(0).__getattr__("f_lineno"));
623 frame.setlocal(7, frame.getlocal(0).__getattr__("f_code"));
624 frame.setlocal(2, frame.getlocal(7).__getattr__("co_filename"));
625 frame.setlocal(3, frame.getlocal(7).__getattr__("co_name"));
626 frame.setlocal(8, frame.getglobal("linecache").__getattr__("getline").__call__(frame.getlocal(2), frame.getlocal(4)));
627 if (frame.getlocal(8).__nonzero__()) {
628 frame.setlocal(8, frame.getlocal(8).invoke("strip"));
631 frame.setlocal(8, frame.getglobal("None"));
633 frame.getlocal(6).invoke("append", new PyTuple(new PyObject[] {frame.getlocal(2), frame.getlocal(4), frame.getlocal(3), frame.getlocal(8)}));
634 frame.setlocal(0, frame.getlocal(0).__getattr__("f_back"));
635 frame.setlocal(5, frame.getlocal(5)._add(i$26));
637 frame.getlocal(6).invoke("reverse");
638 return frame.getlocal(6);
641 private static PyObject tb_lineno$16(PyFrame frame) {
642 // Temporary Variables
644 PyObject t$0$PyObject, t$1$PyObject;
647 /* Calculate correct line number of traceback given in tb.
649 Even works with -O on.
651 frame.setlocal(3, frame.getlocal(0).__getattr__("tb_frame").__getattr__("f_code"));
652 if (frame.getglobal("hasattr").__call__(frame.getlocal(3), s$48).__not__().__nonzero__()) {
653 return frame.getlocal(0).__getattr__("tb_lineno");
655 frame.setlocal(1, frame.getlocal(3).__getattr__("co_lnotab"));
656 frame.setlocal(6, frame.getlocal(3).__getattr__("co_firstlineno"));
657 frame.setlocal(5, frame.getlocal(0).__getattr__("tb_lasti"));
658 frame.setlocal(4, i$24);
660 t$1$PyObject = frame.getglobal("range").__call__(i$24, frame.getglobal("len").__call__(frame.getlocal(1)), i$44);
661 while ((t$0$PyObject = t$1$PyObject.__finditem__(t$0$int++)) != null) {
662 frame.setlocal(2, t$0$PyObject);
663 frame.setlocal(4, frame.getlocal(4)._add(frame.getglobal("ord").__call__(frame.getlocal(1).__getitem__(frame.getlocal(2)))));
664 if (frame.getlocal(4)._gt(frame.getlocal(5)).__nonzero__()) {
667 frame.setlocal(6, frame.getlocal(6)._add(frame.getglobal("ord").__call__(frame.getlocal(1).__getitem__(frame.getlocal(2)._add(i$26)))));
669 return frame.getlocal(6);
672 private static PyObject main$17(PyFrame frame) {
673 frame.setglobal("__file__", s$49);
675 /* Extract, format and print information about Python stack traces. */
676 frame.setlocal("linecache", org.python.core.imp.importOne("linecache", frame));
677 frame.setlocal("sys", org.python.core.imp.importOne("sys", frame));
678 frame.setlocal("types", org.python.core.imp.importOne("types", frame));
679 frame.setlocal("__all__", new PyList(new PyObject[] {s$1, s$2, s$3, s$4, s$5, s$6, s$7, s$8, s$9, s$10, s$11, s$12, s$13}));
680 frame.setlocal("_print", new PyFunction(frame.f_globals, new PyObject[] {s$14, s$15}, c$0__print));
681 frame.setlocal("print_list", new PyFunction(frame.f_globals, new PyObject[] {frame.getname("None")}, c$1_print_list));
682 frame.setlocal("format_list", new PyFunction(frame.f_globals, new PyObject[] {}, c$2_format_list));
683 frame.setlocal("print_tb", new PyFunction(frame.f_globals, new PyObject[] {frame.getname("None"), frame.getname("None")}, c$3_print_tb));
684 frame.setlocal("format_tb", new PyFunction(frame.f_globals, new PyObject[] {frame.getname("None")}, c$4_format_tb));
685 frame.setlocal("extract_tb", new PyFunction(frame.f_globals, new PyObject[] {frame.getname("None")}, c$5_extract_tb));
686 frame.setlocal("print_exception", new PyFunction(frame.f_globals, new PyObject[] {frame.getname("None"), frame.getname("None")}, c$6_print_exception));
687 frame.setlocal("format_exception", new PyFunction(frame.f_globals, new PyObject[] {frame.getname("None")}, c$7_format_exception));
688 frame.setlocal("format_exception_only", new PyFunction(frame.f_globals, new PyObject[] {}, c$8_format_exception_only));
689 frame.setlocal("_some_str", new PyFunction(frame.f_globals, new PyObject[] {}, c$9__some_str));
690 frame.setlocal("print_exc", new PyFunction(frame.f_globals, new PyObject[] {frame.getname("None"), frame.getname("None")}, c$10_print_exc));
691 frame.setlocal("print_last", new PyFunction(frame.f_globals, new PyObject[] {frame.getname("None"), frame.getname("None")}, c$11_print_last));
692 frame.setlocal("print_stack", new PyFunction(frame.f_globals, new PyObject[] {frame.getname("None"), frame.getname("None"), frame.getname("None")}, c$12_print_stack));
693 frame.setlocal("format_stack", new PyFunction(frame.f_globals, new PyObject[] {frame.getname("None"), frame.getname("None")}, c$13_format_stack));
694 frame.setlocal("extract_stack", new PyFunction(frame.f_globals, new PyObject[] {frame.getname("None"), frame.getname("None")}, c$14_extract_stack));
695 frame.setlocal("tb_lineno", new PyFunction(frame.f_globals, new PyObject[] {}, c$15_tb_lineno));
700 public static void moduleDictInit(PyObject dict) {
701 dict.__setitem__("__name__", new PyString("traceback"));
702 Py.runCode(new _PyInner().getMain(), dict, dict);
705 public static void main(String[] args) throws java.lang.Exception {
706 String[] newargs = new String[args.length+1];
707 newargs[0] = "traceback";
708 System.arraycopy(args, 0, newargs, 1, args.length);
709 Py.runMain(traceback._PyInner.class, newargs, traceback.jpy$packages, traceback.jpy$mainProperties, "", new String[] {"string", "random", "util", "traceback", "sre_compile", "atexit", "sre", "sre_constants", "StringIO", "javaos", "socket", "yapm", "calendar", "repr", "copy_reg", "SocketServer", "server", "re", "linecache", "javapath", "UserDict", "copy", "threading", "stat", "PathVFS", "sre_parse"});