annotate Include/traceback.h @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents 7e3ed426962f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
1
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
2 #ifndef Py_TRACEBACK_H
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
3 #define Py_TRACEBACK_H
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
4 #ifdef __cplusplus
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
5 extern "C" {
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
6 #endif
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
7
69070
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
8 #include "pystate.h"
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
9
31739
49ec0d8f08ec Moved tracebackobject to traceback.h, Closes SF Bug #497067
Nicholas Bastin <nick.bastin@gmail.com>
parents: 24752
diff changeset
10 struct _frame;
49ec0d8f08ec Moved tracebackobject to traceback.h, Closes SF Bug #497067
Nicholas Bastin <nick.bastin@gmail.com>
parents: 24752
diff changeset
11
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 /* Traceback interface */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 62389
diff changeset
13 #ifndef Py_LIMITED_API
31739
49ec0d8f08ec Moved tracebackobject to traceback.h, Closes SF Bug #497067
Nicholas Bastin <nick.bastin@gmail.com>
parents: 24752
diff changeset
14 typedef struct _traceback {
62389
907f564476be Issue #6543: Write the traceback in the terminal encoding instead of utf-8.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 48499
diff changeset
15 PyObject_HEAD
907f564476be Issue #6543: Write the traceback in the terminal encoding instead of utf-8.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 48499
diff changeset
16 struct _traceback *tb_next;
907f564476be Issue #6543: Write the traceback in the terminal encoding instead of utf-8.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 48499
diff changeset
17 struct _frame *tb_frame;
907f564476be Issue #6543: Write the traceback in the terminal encoding instead of utf-8.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 48499
diff changeset
18 int tb_lasti;
907f564476be Issue #6543: Write the traceback in the terminal encoding instead of utf-8.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 48499
diff changeset
19 int tb_lineno;
31739
49ec0d8f08ec Moved tracebackobject to traceback.h, Closes SF Bug #497067
Nicholas Bastin <nick.bastin@gmail.com>
parents: 24752
diff changeset
20 } PyTracebackObject;
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 62389
diff changeset
21 #endif
2043
4ebee904924e Lots of small things, see ChangeLog
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
22
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 22527
diff changeset
23 PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 22527
diff changeset
24 PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 62389
diff changeset
25 #ifndef Py_LIMITED_API
62389
907f564476be Issue #6543: Write the traceback in the terminal encoding instead of utf-8.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 48499
diff changeset
26 PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 62389
diff changeset
27 #endif
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
28
22527
a2fe0ecd0ce2 backport akuchling's checkin of
Michael W. Hudson <mwh@python.net>
parents: 14375
diff changeset
29 /* Reveal traceback type so we can typecheck traceback objects */
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 22527
diff changeset
30 PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
31 #define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type)
2841
64928f6a8e80 keyword arguments and faster function calls
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
32
69070
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
33 /* Write the Python traceback into the file 'fd'. For example:
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
34
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
35 Traceback (most recent call first):
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
36 File "xxx", line xxx in <xxx>
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
37 File "xxx", line xxx in <xxx>
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
38 ...
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
39 File "xxx", line xxx in <xxx>
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
40
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
41 This function is written for debug purpose only, to dump the traceback in
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
42 the worst case: after a segmentation fault, at fatal error, etc. That's why,
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
43 it is very limited. Strings are truncated to 100 characters and encoded to
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
44 ASCII with backslashreplace. It doesn't write the source code, only the
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
45 function name, filename and line number of each frame. Write only the first
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
46 100 frames: if the traceback is truncated, write the line " ...".
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
47
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
48 This function is signal safe. */
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
49
69102
7e3ed426962f Issue #11393: _Py_DumpTraceback() writes the header even if there is no frame
Victor Stinner <victor.stinner@haypocalc.com>
parents: 69070
diff changeset
50 PyAPI_DATA(void) _Py_DumpTraceback(
69070
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
51 int fd,
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
52 PyThreadState *tstate);
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
53
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
54 /* Write the traceback of all threads into the file 'fd'. current_thread can be
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
55 NULL. Return NULL on success, or an error message on error.
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
56
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
57 This function is written for debug purpose only. It calls
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
58 _Py_DumpTraceback() for each thread, and so has the same limitations. It
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
59 only write the traceback of the first 100 threads: write "..." if there are
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
60 more threads.
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
61
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
62 This function is signal safe. */
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
63
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
64 PyAPI_DATA(const char*) _Py_DumpTracebackThreads(
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
65 int fd, PyInterpreterState *interp,
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
66 PyThreadState *current_thread);
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
67
b0680b5a5215 Issue #11393: Add the new faulthandler module
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
68
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
69 #ifdef __cplusplus
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
70 }
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
71 #endif
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
72 #endif /* !Py_TRACEBACK_H */