Mercurial > cpython-lru_cache-weakref
annotate Python/exceptions.c @ 26923:dbfc3ef7d003 legacy-trunk
Since the *_Init() are private, prefix with _, suggested by Skip
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Tue, 31 Dec 2002 03:42:13 +0000 |
| parents | b9c912e2c3c0 |
| children | faabd9867fb8 |
| rev | line source |
|---|---|
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1 /* This module provides the suite of standard class-based exceptions for |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
2 * Python's builtin module. This is a complete C implementation of what, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
3 * in Python 1.5.2, was contained in the exceptions.py module. The problem |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
4 * there was that if exceptions.py could not be imported for some reason, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
5 * the entire interpreter would abort. |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
6 * |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
7 * By moving the exceptions into C and statically linking, we can guarantee |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
8 * that the standard exceptions will always be available. |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
9 * |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
10 * history: |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
11 * 98-08-19 fl created (for pyexe) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
12 * 00-02-08 fl updated for 1.5.2 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
13 * 26-May-2000 baw vetted for Python 1.6 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
14 * |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
15 * written by Fredrik Lundh |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
16 * modifications, additions, cleanups, and proofreading by Barry Warsaw |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
17 * |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
18 * Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
19 */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
20 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
21 #include "Python.h" |
|
13996
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
22 #include "osdefs.h" |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
23 |
|
13565
e558eb228a46
Worm around MSVC6 error on single string literal > 2Kb.
Tim Peters <tim.peters@gmail.com>
parents:
13539
diff
changeset
|
24 /* Caution: MS Visual C++ 6 errors if a single string literal exceeds |
|
e558eb228a46
Worm around MSVC6 error on single string literal > 2Kb.
Tim Peters <tim.peters@gmail.com>
parents:
13539
diff
changeset
|
25 * 2Kb. So the module docstring has been broken roughly in half, using |
|
e558eb228a46
Worm around MSVC6 error on single string literal > 2Kb.
Tim Peters <tim.peters@gmail.com>
parents:
13539
diff
changeset
|
26 * compile-time literal concatenation. |
|
e558eb228a46
Worm around MSVC6 error on single string literal > 2Kb.
Tim Peters <tim.peters@gmail.com>
parents:
13539
diff
changeset
|
27 */ |
|
22629
7230e01c3c49
add comment reminding people about class hierarchy in Doc/lib/libexcs.tex
Skip Montanaro <skip@pobox.com>
parents:
22121
diff
changeset
|
28 |
|
7230e01c3c49
add comment reminding people about class hierarchy in Doc/lib/libexcs.tex
Skip Montanaro <skip@pobox.com>
parents:
22121
diff
changeset
|
29 /* NOTE: If the exception class hierarchy changes, don't forget to update |
|
7230e01c3c49
add comment reminding people about class hierarchy in Doc/lib/libexcs.tex
Skip Montanaro <skip@pobox.com>
parents:
22121
diff
changeset
|
30 * Doc/lib/libexcs.tex! |
|
7230e01c3c49
add comment reminding people about class hierarchy in Doc/lib/libexcs.tex
Skip Montanaro <skip@pobox.com>
parents:
22121
diff
changeset
|
31 */ |
|
7230e01c3c49
add comment reminding people about class hierarchy in Doc/lib/libexcs.tex
Skip Montanaro <skip@pobox.com>
parents:
22121
diff
changeset
|
32 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
33 PyDoc_STRVAR(module__doc__, |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
34 "Python's standard exception class hierarchy.\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
35 \n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
36 Before Python 1.5, the standard exceptions were all simple string objects.\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
37 In Python 1.5, the standard exceptions were converted to classes organized\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
38 into a relatively flat hierarchy. String-based standard exceptions were\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
39 optional, or used as a fallback if some problem occurred while importing\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
40 the exception module. With Python 1.6, optional string-based standard\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
41 exceptions were removed (along with the -X command line flag).\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
42 \n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
43 The class exceptions were implemented in such a way as to be almost\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
44 completely backward compatible. Some tricky uses of IOError could\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
45 potentially have broken, but by Python 1.6, all of these should have\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
46 been fixed. As of Python 1.6, the class-based standard exceptions are\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
47 now implemented in C, and are guaranteed to exist in the Python\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
48 interpreter.\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
49 \n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
50 Here is a rundown of the class hierarchy. The classes found here are\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
51 inserted into both the exceptions module and the `built-in' module. It is\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
52 recommended that user defined class based exceptions be derived from the\n\ |
|
13565
e558eb228a46
Worm around MSVC6 error on single string literal > 2Kb.
Tim Peters <tim.peters@gmail.com>
parents:
13539
diff
changeset
|
53 `Exception' class, although this is currently not enforced.\n" |
|
e558eb228a46
Worm around MSVC6 error on single string literal > 2Kb.
Tim Peters <tim.peters@gmail.com>
parents:
13539
diff
changeset
|
54 /* keep string pieces "small" */ |
|
e558eb228a46
Worm around MSVC6 error on single string literal > 2Kb.
Tim Peters <tim.peters@gmail.com>
parents:
13539
diff
changeset
|
55 "\n\ |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
56 Exception\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
57 |\n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
58 +-- SystemExit\n\ |
|
17597
32e7d0898eab
Iterators phase 1. This comprises:
Guido van Rossum <guido@python.org>
parents:
17518
diff
changeset
|
59 +-- StopIteration\n\ |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
60 +-- StandardError\n\ |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
61 | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
62 | +-- KeyboardInterrupt\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
63 | +-- ImportError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
64 | +-- EnvironmentError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
65 | | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
66 | | +-- IOError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
67 | | +-- OSError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
68 | | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
69 | | +-- WindowsError\n\ |
|
26550
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
26318
diff
changeset
|
70 | | +-- VMSError\n\ |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
71 | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
72 | +-- EOFError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
73 | +-- RuntimeError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
74 | | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
75 | | +-- NotImplementedError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
76 | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
77 | +-- NameError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
78 | | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
79 | | +-- UnboundLocalError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
80 | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
81 | +-- AttributeError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
82 | +-- SyntaxError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
83 | | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
84 | | +-- IndentationError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
85 | | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
86 | | +-- TabError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
87 | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
88 | +-- TypeError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
89 | +-- AssertionError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
90 | +-- LookupError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
91 | | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
92 | | +-- IndexError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
93 | | +-- KeyError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
94 | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
95 | +-- ArithmeticError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
96 | | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
97 | | +-- OverflowError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
98 | | +-- ZeroDivisionError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
99 | | +-- FloatingPointError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
100 | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
101 | +-- ValueError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
102 | | |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
103 | | +-- UnicodeError\n\ |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
104 | | |\n\ |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
105 | | +-- UnicodeEncodeError\n\ |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
106 | | +-- UnicodeDecodeError\n\ |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
107 | | +-- UnicodeTranslateError\n\ |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
108 | |\n\ |
|
20279
8b3ea7335c1b
weakref.ReferenceError becomes a built-in exception now that weak ref objects
Fred Drake <fdrake@acm.org>
parents:
19433
diff
changeset
|
109 | +-- ReferenceError\n\ |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
110 | +-- SystemError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
111 | +-- MemoryError\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
112 |\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
113 +---Warning\n\ |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
114 |\n\ |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
115 +-- UserWarning\n\ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
116 +-- DeprecationWarning\n\ |
|
23564
3f242cdd0904
As discussed on python-dev, add a mechanism to indicate features
Neal Norwitz <nnorwitz@gmail.com>
parents:
22629
diff
changeset
|
117 +-- PendingDeprecationWarning\n\ |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
118 +-- SyntaxWarning\n\ |
|
19433
5d81c6bff306
Introduce OverflowWarning -- to be issued when short int operations
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
119 +-- OverflowWarning\n\ |
|
24818
31d2860089e6
Added a FutureWarning for constructs that will change semantically in
Barry Warsaw <barry@python.org>
parents:
24420
diff
changeset
|
120 +-- RuntimeWarning\n\ |
|
31d2860089e6
Added a FutureWarning for constructs that will change semantically in
Barry Warsaw <barry@python.org>
parents:
24420
diff
changeset
|
121 +-- FutureWarning" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
122 ); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
123 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
124 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
125 /* Helper function for populating a dictionary with method wrappers. */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
126 static int |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
127 populate_methods(PyObject *klass, PyObject *dict, PyMethodDef *methods) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
128 { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
129 if (!methods) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
130 return 0; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
131 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
132 while (methods->ml_name) { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
133 /* get a wrapper for the built-in function */ |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
134 PyObject *func = PyCFunction_New(methods, NULL); |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
135 PyObject *meth; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
136 int status; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
137 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
138 if (!func) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
139 return -1; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
140 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
141 /* turn the function into an unbound method */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
142 if (!(meth = PyMethod_New(func, NULL, klass))) { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
143 Py_DECREF(func); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
144 return -1; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
145 } |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
146 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
147 /* add method to dictionary */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
148 status = PyDict_SetItemString(dict, methods->ml_name, meth); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
149 Py_DECREF(meth); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
150 Py_DECREF(func); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
151 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
152 /* stop now if an error occurred, otherwise do the next method */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
153 if (status) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
154 return status; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
155 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
156 methods++; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
157 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
158 return 0; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
159 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
160 |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
161 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
162 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
163 /* This function is used to create all subsequent exception classes. */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
164 static int |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
165 make_class(PyObject **klass, PyObject *base, |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
166 char *name, PyMethodDef *methods, |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
167 char *docstr) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
168 { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
169 PyObject *dict = PyDict_New(); |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
170 PyObject *str = NULL; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
171 int status = -1; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
172 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
173 if (!dict) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
174 return -1; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
175 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
176 /* If an error occurs from here on, goto finally instead of explicitly |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
177 * returning NULL. |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
178 */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
179 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
180 if (docstr) { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
181 if (!(str = PyString_FromString(docstr))) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
182 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
183 if (PyDict_SetItemString(dict, "__doc__", str)) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
184 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
185 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
186 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
187 if (!(*klass = PyErr_NewException(name, base, dict))) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
188 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
189 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
190 if (populate_methods(*klass, dict, methods)) { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
191 Py_DECREF(*klass); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
192 *klass = NULL; |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
193 goto finally; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
194 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
195 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
196 status = 0; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
197 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
198 finally: |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
199 Py_XDECREF(dict); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
200 Py_XDECREF(str); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
201 return status; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
202 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
203 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
204 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
205 /* Use this for *args signatures, otherwise just use PyArg_ParseTuple() */ |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
206 static PyObject * |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
207 get_self(PyObject *args) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
208 { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
209 PyObject *self = PyTuple_GetItem(args, 0); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
210 if (!self) { |
|
13620
5b727ab37092
Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents:
13576
diff
changeset
|
211 /* Watch out for being called to early in the bootstrapping process */ |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
212 if (PyExc_TypeError) { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
213 PyErr_SetString(PyExc_TypeError, |
| 15318 | 214 "unbound method must be called with instance as first argument"); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
215 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
216 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
217 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
218 return self; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
219 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
220 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
221 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
222 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
223 /* Notes on bootstrapping the exception classes. |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
224 * |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
225 * First thing we create is the base class for all exceptions, called |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
226 * appropriately enough: Exception. Creation of this class makes no |
|
13182
1e302d996d58
replace constant 1 with symbolic constant METH_VARARGS
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
12968
diff
changeset
|
227 * assumptions about the existence of any other exception class -- except |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
228 * for TypeError, which can conditionally exist. |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
229 * |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
230 * Next, StandardError is created (which is quite simple) followed by |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
231 * TypeError, because the instantiation of other exceptions can potentially |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
232 * throw a TypeError. Once these exceptions are created, all the others |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
233 * can be created in any order. See the static exctable below for the |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
234 * explicit bootstrap order. |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
235 * |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
236 * All classes after Exception can be created using PyErr_NewException(). |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
237 */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
238 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
239 PyDoc_STRVAR(Exception__doc__, "Common base class for all exceptions."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
240 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
241 |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
242 static PyObject * |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
243 Exception__init__(PyObject *self, PyObject *args) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
244 { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
245 int status; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
246 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
247 if (!(self = get_self(args))) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
248 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
249 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
250 /* set args attribute */ |
|
13576
61e4c29d53d8
replace PyXXX_Length calls with PyXXX_Size calls
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13565
diff
changeset
|
251 /* XXX size is only a hint */ |
|
61e4c29d53d8
replace PyXXX_Length calls with PyXXX_Size calls
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13565
diff
changeset
|
252 args = PySequence_GetSlice(args, 1, PySequence_Size(args)); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
253 if (!args) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
254 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
255 status = PyObject_SetAttrString(self, "args", args); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
256 Py_DECREF(args); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
257 if (status < 0) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
258 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
259 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
260 Py_INCREF(Py_None); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
261 return Py_None; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
262 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
263 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
264 |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
265 static PyObject * |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
266 Exception__str__(PyObject *self, PyObject *args) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
267 { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
268 PyObject *out; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
269 |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
270 if (!PyArg_ParseTuple(args, "O:__str__", &self)) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
271 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
272 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
273 args = PyObject_GetAttrString(self, "args"); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
274 if (!args) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
275 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
276 |
|
13576
61e4c29d53d8
replace PyXXX_Length calls with PyXXX_Size calls
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13565
diff
changeset
|
277 switch (PySequence_Size(args)) { |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
278 case 0: |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
279 out = PyString_FromString(""); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
280 break; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
281 case 1: |
|
13484
67fd19d74528
Exception__str__(): In case 1, be sure to decref the tmp local
Barry Warsaw <barry@python.org>
parents:
13453
diff
changeset
|
282 { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
283 PyObject *tmp = PySequence_GetItem(args, 0); |
|
13484
67fd19d74528
Exception__str__(): In case 1, be sure to decref the tmp local
Barry Warsaw <barry@python.org>
parents:
13453
diff
changeset
|
284 if (tmp) { |
|
67fd19d74528
Exception__str__(): In case 1, be sure to decref the tmp local
Barry Warsaw <barry@python.org>
parents:
13453
diff
changeset
|
285 out = PyObject_Str(tmp); |
|
67fd19d74528
Exception__str__(): In case 1, be sure to decref the tmp local
Barry Warsaw <barry@python.org>
parents:
13453
diff
changeset
|
286 Py_DECREF(tmp); |
|
67fd19d74528
Exception__str__(): In case 1, be sure to decref the tmp local
Barry Warsaw <barry@python.org>
parents:
13453
diff
changeset
|
287 } |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
288 else |
|
13484
67fd19d74528
Exception__str__(): In case 1, be sure to decref the tmp local
Barry Warsaw <barry@python.org>
parents:
13453
diff
changeset
|
289 out = NULL; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
290 break; |
|
13484
67fd19d74528
Exception__str__(): In case 1, be sure to decref the tmp local
Barry Warsaw <barry@python.org>
parents:
13453
diff
changeset
|
291 } |
|
25320
14ad560f4a97
Fix SF bug 610610 (reported by Martijn Pieters, diagnosed by Neal Norwitz).
Guido van Rossum <guido@python.org>
parents:
25110
diff
changeset
|
292 case -1: |
|
14ad560f4a97
Fix SF bug 610610 (reported by Martijn Pieters, diagnosed by Neal Norwitz).
Guido van Rossum <guido@python.org>
parents:
25110
diff
changeset
|
293 PyErr_Clear(); |
|
14ad560f4a97
Fix SF bug 610610 (reported by Martijn Pieters, diagnosed by Neal Norwitz).
Guido van Rossum <guido@python.org>
parents:
25110
diff
changeset
|
294 /* Fall through */ |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
295 default: |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
296 out = PyObject_Str(args); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
297 break; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
298 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
299 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
300 Py_DECREF(args); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
301 return out; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
302 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
303 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
304 |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
305 static PyObject * |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
306 Exception__getitem__(PyObject *self, PyObject *args) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
307 { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
308 PyObject *out; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
309 PyObject *index; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
310 |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
311 if (!PyArg_ParseTuple(args, "OO:__getitem__", &self, &index)) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
312 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
313 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
314 args = PyObject_GetAttrString(self, "args"); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
315 if (!args) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
316 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
317 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
318 out = PyObject_GetItem(args, index); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
319 Py_DECREF(args); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
320 return out; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
321 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
322 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
323 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
324 static PyMethodDef |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
325 Exception_methods[] = { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
326 /* methods for the Exception class */ |
|
13182
1e302d996d58
replace constant 1 with symbolic constant METH_VARARGS
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
12968
diff
changeset
|
327 { "__getitem__", Exception__getitem__, METH_VARARGS}, |
|
1e302d996d58
replace constant 1 with symbolic constant METH_VARARGS
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
12968
diff
changeset
|
328 { "__str__", Exception__str__, METH_VARARGS}, |
|
1e302d996d58
replace constant 1 with symbolic constant METH_VARARGS
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
12968
diff
changeset
|
329 { "__init__", Exception__init__, METH_VARARGS}, |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
330 { NULL, NULL } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
331 }; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
332 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
333 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
334 static int |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
335 make_Exception(char *modulename) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
336 { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
337 PyObject *dict = PyDict_New(); |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
338 PyObject *str = NULL; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
339 PyObject *name = NULL; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
340 int status = -1; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
341 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
342 if (!dict) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
343 return -1; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
344 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
345 /* If an error occurs from here on, goto finally instead of explicitly |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
346 * returning NULL. |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
347 */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
348 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
349 if (!(str = PyString_FromString(modulename))) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
350 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
351 if (PyDict_SetItemString(dict, "__module__", str)) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
352 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
353 Py_DECREF(str); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
354 if (!(str = PyString_FromString(Exception__doc__))) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
355 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
356 if (PyDict_SetItemString(dict, "__doc__", str)) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
357 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
358 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
359 if (!(name = PyString_FromString("Exception"))) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
360 goto finally; |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
361 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
362 if (!(PyExc_Exception = PyClass_New(NULL, dict, name))) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
363 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
364 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
365 /* Now populate the dictionary with the method suite */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
366 if (populate_methods(PyExc_Exception, dict, Exception_methods)) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
367 /* Don't need to reclaim PyExc_Exception here because that'll |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
368 * happen during interpreter shutdown. |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
369 */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
370 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
371 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
372 status = 0; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
373 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
374 finally: |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
375 Py_XDECREF(dict); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
376 Py_XDECREF(str); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
377 Py_XDECREF(name); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
378 return status; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
379 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
380 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
381 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
382 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
383 PyDoc_STRVAR(StandardError__doc__, |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
384 "Base class for all standard Python exceptions."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
385 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
386 PyDoc_STRVAR(TypeError__doc__, "Inappropriate argument type."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
387 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
388 PyDoc_STRVAR(StopIteration__doc__, "Signal the end from iterator.next()."); |
|
17597
32e7d0898eab
Iterators phase 1. This comprises:
Guido van Rossum <guido@python.org>
parents:
17518
diff
changeset
|
389 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
390 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
391 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
392 PyDoc_STRVAR(SystemExit__doc__, "Request to exit from the interpreter."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
393 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
394 |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
395 static PyObject * |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
396 SystemExit__init__(PyObject *self, PyObject *args) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
397 { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
398 PyObject *code; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
399 int status; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
400 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
401 if (!(self = get_self(args))) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
402 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
403 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
404 /* Set args attribute. */ |
|
13576
61e4c29d53d8
replace PyXXX_Length calls with PyXXX_Size calls
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13565
diff
changeset
|
405 if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
406 return NULL; |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
407 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
408 status = PyObject_SetAttrString(self, "args", args); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
409 if (status < 0) { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
410 Py_DECREF(args); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
411 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
412 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
413 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
414 /* set code attribute */ |
|
13576
61e4c29d53d8
replace PyXXX_Length calls with PyXXX_Size calls
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13565
diff
changeset
|
415 switch (PySequence_Size(args)) { |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
416 case 0: |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
417 Py_INCREF(Py_None); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
418 code = Py_None; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
419 break; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
420 case 1: |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
421 code = PySequence_GetItem(args, 0); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
422 break; |
|
25325
6b62ab8485eb
Two more cases of switch(PySequence_Size()) without checking for case -1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
25320
diff
changeset
|
423 case -1: |
|
6b62ab8485eb
Two more cases of switch(PySequence_Size()) without checking for case -1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
25320
diff
changeset
|
424 PyErr_Clear(); |
|
6b62ab8485eb
Two more cases of switch(PySequence_Size()) without checking for case -1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
25320
diff
changeset
|
425 /* Fall through */ |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
426 default: |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
427 Py_INCREF(args); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
428 code = args; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
429 break; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
430 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
431 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
432 status = PyObject_SetAttrString(self, "code", code); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
433 Py_DECREF(code); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
434 Py_DECREF(args); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
435 if (status < 0) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
436 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
437 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
438 Py_INCREF(Py_None); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
439 return Py_None; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
440 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
441 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
442 |
|
17518
f939ce52a734
Make some private symbols static.
Guido van Rossum <guido@python.org>
parents:
16852
diff
changeset
|
443 static PyMethodDef SystemExit_methods[] = { |
|
13182
1e302d996d58
replace constant 1 with symbolic constant METH_VARARGS
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
12968
diff
changeset
|
444 { "__init__", SystemExit__init__, METH_VARARGS}, |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
445 {NULL, NULL} |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
446 }; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
447 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
448 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
449 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
450 PyDoc_STRVAR(KeyboardInterrupt__doc__, "Program interrupted by user."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
451 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
452 PyDoc_STRVAR(ImportError__doc__, |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
453 "Import can't find module, or can't find name in module."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
454 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
455 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
456 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
457 PyDoc_STRVAR(EnvironmentError__doc__, "Base class for I/O related errors."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
458 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
459 |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
460 static PyObject * |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
461 EnvironmentError__init__(PyObject *self, PyObject *args) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
462 { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
463 PyObject *item0 = NULL; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
464 PyObject *item1 = NULL; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
465 PyObject *item2 = NULL; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
466 PyObject *subslice = NULL; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
467 PyObject *rtnval = NULL; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
468 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
469 if (!(self = get_self(args))) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
470 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
471 |
|
13576
61e4c29d53d8
replace PyXXX_Length calls with PyXXX_Size calls
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13565
diff
changeset
|
472 if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
473 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
474 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
475 if (PyObject_SetAttrString(self, "args", args) || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
476 PyObject_SetAttrString(self, "errno", Py_None) || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
477 PyObject_SetAttrString(self, "strerror", Py_None) || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
478 PyObject_SetAttrString(self, "filename", Py_None)) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
479 { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
480 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
481 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
482 |
|
13576
61e4c29d53d8
replace PyXXX_Length calls with PyXXX_Size calls
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13565
diff
changeset
|
483 switch (PySequence_Size(args)) { |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
484 case 3: |
|
13453
d6198e703602
EnvironmentError__init__(): The two case clauses were missing
Barry Warsaw <barry@python.org>
parents:
13283
diff
changeset
|
485 /* Where a function has a single filename, such as open() or some |
|
d6198e703602
EnvironmentError__init__(): The two case clauses were missing
Barry Warsaw <barry@python.org>
parents:
13283
diff
changeset
|
486 * of the os module functions, PyErr_SetFromErrnoWithFilename() is |
|
d6198e703602
EnvironmentError__init__(): The two case clauses were missing
Barry Warsaw <barry@python.org>
parents:
13283
diff
changeset
|
487 * called, giving a third argument which is the filename. But, so |
|
d6198e703602
EnvironmentError__init__(): The two case clauses were missing
Barry Warsaw <barry@python.org>
parents:
13283
diff
changeset
|
488 * that old code using in-place unpacking doesn't break, e.g.: |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
489 * |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
490 * except IOError, (errno, strerror): |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
491 * |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
492 * we hack args so that it only contains two items. This also |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
493 * means we need our own __str__() which prints out the filename |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
494 * when it was supplied. |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
495 */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
496 item0 = PySequence_GetItem(args, 0); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
497 item1 = PySequence_GetItem(args, 1); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
498 item2 = PySequence_GetItem(args, 2); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
499 if (!item0 || !item1 || !item2) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
500 goto finally; |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
501 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
502 if (PyObject_SetAttrString(self, "errno", item0) || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
503 PyObject_SetAttrString(self, "strerror", item1) || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
504 PyObject_SetAttrString(self, "filename", item2)) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
505 { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
506 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
507 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
508 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
509 subslice = PySequence_GetSlice(args, 0, 2); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
510 if (!subslice || PyObject_SetAttrString(self, "args", subslice)) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
511 goto finally; |
|
13453
d6198e703602
EnvironmentError__init__(): The two case clauses were missing
Barry Warsaw <barry@python.org>
parents:
13283
diff
changeset
|
512 break; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
513 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
514 case 2: |
|
13453
d6198e703602
EnvironmentError__init__(): The two case clauses were missing
Barry Warsaw <barry@python.org>
parents:
13283
diff
changeset
|
515 /* Used when PyErr_SetFromErrno() is called and no filename |
|
d6198e703602
EnvironmentError__init__(): The two case clauses were missing
Barry Warsaw <barry@python.org>
parents:
13283
diff
changeset
|
516 * argument is given. |
|
d6198e703602
EnvironmentError__init__(): The two case clauses were missing
Barry Warsaw <barry@python.org>
parents:
13283
diff
changeset
|
517 */ |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
518 item0 = PySequence_GetItem(args, 0); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
519 item1 = PySequence_GetItem(args, 1); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
520 if (!item0 || !item1) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
521 goto finally; |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
522 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
523 if (PyObject_SetAttrString(self, "errno", item0) || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
524 PyObject_SetAttrString(self, "strerror", item1)) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
525 { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
526 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
527 } |
|
13453
d6198e703602
EnvironmentError__init__(): The two case clauses were missing
Barry Warsaw <barry@python.org>
parents:
13283
diff
changeset
|
528 break; |
|
25325
6b62ab8485eb
Two more cases of switch(PySequence_Size()) without checking for case -1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
25320
diff
changeset
|
529 |
|
6b62ab8485eb
Two more cases of switch(PySequence_Size()) without checking for case -1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
25320
diff
changeset
|
530 case -1: |
|
6b62ab8485eb
Two more cases of switch(PySequence_Size()) without checking for case -1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
25320
diff
changeset
|
531 PyErr_Clear(); |
|
6b62ab8485eb
Two more cases of switch(PySequence_Size()) without checking for case -1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
25320
diff
changeset
|
532 break; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
533 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
534 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
535 Py_INCREF(Py_None); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
536 rtnval = Py_None; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
537 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
538 finally: |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
539 Py_DECREF(args); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
540 Py_XDECREF(item0); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
541 Py_XDECREF(item1); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
542 Py_XDECREF(item2); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
543 Py_XDECREF(subslice); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
544 return rtnval; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
545 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
546 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
547 |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
548 static PyObject * |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
549 EnvironmentError__str__(PyObject *self, PyObject *args) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
550 { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
551 PyObject *originalself = self; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
552 PyObject *filename; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
553 PyObject *serrno; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
554 PyObject *strerror; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
555 PyObject *rtnval = NULL; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
556 |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
557 if (!PyArg_ParseTuple(args, "O:__str__", &self)) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
558 return NULL; |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
559 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
560 filename = PyObject_GetAttrString(self, "filename"); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
561 serrno = PyObject_GetAttrString(self, "errno"); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
562 strerror = PyObject_GetAttrString(self, "strerror"); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
563 if (!filename || !serrno || !strerror) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
564 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
565 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
566 if (filename != Py_None) { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
567 PyObject *fmt = PyString_FromString("[Errno %s] %s: %s"); |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
568 PyObject *repr = PyObject_Repr(filename); |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
569 PyObject *tuple = PyTuple_New(3); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
570 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
571 if (!fmt || !repr || !tuple) { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
572 Py_XDECREF(fmt); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
573 Py_XDECREF(repr); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
574 Py_XDECREF(tuple); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
575 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
576 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
577 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
578 PyTuple_SET_ITEM(tuple, 0, serrno); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
579 PyTuple_SET_ITEM(tuple, 1, strerror); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
580 PyTuple_SET_ITEM(tuple, 2, repr); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
581 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
582 rtnval = PyString_Format(fmt, tuple); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
583 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
584 Py_DECREF(fmt); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
585 Py_DECREF(tuple); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
586 /* already freed because tuple owned only reference */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
587 serrno = NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
588 strerror = NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
589 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
590 else if (PyObject_IsTrue(serrno) && PyObject_IsTrue(strerror)) { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
591 PyObject *fmt = PyString_FromString("[Errno %s] %s"); |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
592 PyObject *tuple = PyTuple_New(2); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
593 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
594 if (!fmt || !tuple) { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
595 Py_XDECREF(fmt); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
596 Py_XDECREF(tuple); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
597 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
598 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
599 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
600 PyTuple_SET_ITEM(tuple, 0, serrno); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
601 PyTuple_SET_ITEM(tuple, 1, strerror); |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
602 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
603 rtnval = PyString_Format(fmt, tuple); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
604 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
605 Py_DECREF(fmt); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
606 Py_DECREF(tuple); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
607 /* already freed because tuple owned only reference */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
608 serrno = NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
609 strerror = NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
610 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
611 else |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
612 /* The original Python code said: |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
613 * |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
614 * return StandardError.__str__(self) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
615 * |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
616 * but there is no StandardError__str__() function; we happen to |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
617 * know that's just a pass through to Exception__str__(). |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
618 */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
619 rtnval = Exception__str__(originalself, args); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
620 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
621 finally: |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
622 Py_XDECREF(filename); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
623 Py_XDECREF(serrno); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
624 Py_XDECREF(strerror); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
625 return rtnval; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
626 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
627 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
628 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
629 static |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
630 PyMethodDef EnvironmentError_methods[] = { |
|
13182
1e302d996d58
replace constant 1 with symbolic constant METH_VARARGS
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
12968
diff
changeset
|
631 {"__init__", EnvironmentError__init__, METH_VARARGS}, |
|
1e302d996d58
replace constant 1 with symbolic constant METH_VARARGS
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
12968
diff
changeset
|
632 {"__str__", EnvironmentError__str__, METH_VARARGS}, |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
633 {NULL, NULL} |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
634 }; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
635 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
636 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
637 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
638 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
639 PyDoc_STRVAR(IOError__doc__, "I/O operation failed."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
640 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
641 PyDoc_STRVAR(OSError__doc__, "OS system call failed."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
642 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
643 #ifdef MS_WINDOWS |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
644 PyDoc_STRVAR(WindowsError__doc__, "MS-Windows OS system call failed."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
645 #endif /* MS_WINDOWS */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
646 |
|
26550
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
26318
diff
changeset
|
647 #ifdef __VMS |
|
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
26318
diff
changeset
|
648 static char |
|
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
26318
diff
changeset
|
649 VMSError__doc__[] = "OpenVMS OS system call failed."; |
|
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
26318
diff
changeset
|
650 #endif |
|
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
26318
diff
changeset
|
651 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
652 PyDoc_STRVAR(EOFError__doc__, "Read beyond end of file."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
653 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
654 PyDoc_STRVAR(RuntimeError__doc__, "Unspecified run-time error."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
655 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
656 PyDoc_STRVAR(NotImplementedError__doc__, |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
657 "Method or function hasn't been implemented yet."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
658 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
659 PyDoc_STRVAR(NameError__doc__, "Name not found globally."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
660 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
661 PyDoc_STRVAR(UnboundLocalError__doc__, |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
662 "Local name referenced but not bound to a value."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
663 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
664 PyDoc_STRVAR(AttributeError__doc__, "Attribute not found."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
665 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
666 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
667 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
668 PyDoc_STRVAR(SyntaxError__doc__, "Invalid syntax."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
669 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
670 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
671 static int |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
672 SyntaxError__classinit__(PyObject *klass) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
673 { |
|
14054
e8301612e7d8
SyntaxError__classinit__(): Slight reorg for simplicity.
Barry Warsaw <barry@python.org>
parents:
14013
diff
changeset
|
674 int retval = 0; |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
675 PyObject *emptystring = PyString_FromString(""); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
676 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
677 /* Additional class-creation time initializations */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
678 if (!emptystring || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
679 PyObject_SetAttrString(klass, "msg", emptystring) || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
680 PyObject_SetAttrString(klass, "filename", Py_None) || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
681 PyObject_SetAttrString(klass, "lineno", Py_None) || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
682 PyObject_SetAttrString(klass, "offset", Py_None) || |
|
22121
d4406fbfcb4e
Patch #50002: Display line information for bad \x escapes:
Martin v. Löwis <martin@v.loewis.de>
parents:
21072
diff
changeset
|
683 PyObject_SetAttrString(klass, "text", Py_None) || |
|
d4406fbfcb4e
Patch #50002: Display line information for bad \x escapes:
Martin v. Löwis <martin@v.loewis.de>
parents:
21072
diff
changeset
|
684 PyObject_SetAttrString(klass, "print_file_and_line", Py_None)) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
685 { |
|
14054
e8301612e7d8
SyntaxError__classinit__(): Slight reorg for simplicity.
Barry Warsaw <barry@python.org>
parents:
14013
diff
changeset
|
686 retval = -1; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
687 } |
|
14054
e8301612e7d8
SyntaxError__classinit__(): Slight reorg for simplicity.
Barry Warsaw <barry@python.org>
parents:
14013
diff
changeset
|
688 Py_XDECREF(emptystring); |
|
e8301612e7d8
SyntaxError__classinit__(): Slight reorg for simplicity.
Barry Warsaw <barry@python.org>
parents:
14013
diff
changeset
|
689 return retval; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
690 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
691 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
692 |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
693 static PyObject * |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
694 SyntaxError__init__(PyObject *self, PyObject *args) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
695 { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
696 PyObject *rtnval = NULL; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
697 int lenargs; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
698 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
699 if (!(self = get_self(args))) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
700 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
701 |
|
13576
61e4c29d53d8
replace PyXXX_Length calls with PyXXX_Size calls
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13565
diff
changeset
|
702 if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
703 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
704 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
705 if (PyObject_SetAttrString(self, "args", args)) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
706 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
707 |
|
13576
61e4c29d53d8
replace PyXXX_Length calls with PyXXX_Size calls
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13565
diff
changeset
|
708 lenargs = PySequence_Size(args); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
709 if (lenargs >= 1) { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
710 PyObject *item0 = PySequence_GetItem(args, 0); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
711 int status; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
712 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
713 if (!item0) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
714 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
715 status = PyObject_SetAttrString(self, "msg", item0); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
716 Py_DECREF(item0); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
717 if (status) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
718 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
719 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
720 if (lenargs == 2) { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
721 PyObject *info = PySequence_GetItem(args, 1); |
|
16852
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
722 PyObject *filename = NULL, *lineno = NULL; |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
723 PyObject *offset = NULL, *text = NULL; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
724 int status = 1; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
725 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
726 if (!info) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
727 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
728 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
729 filename = PySequence_GetItem(info, 0); |
|
16852
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
730 if (filename != NULL) { |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
731 lineno = PySequence_GetItem(info, 1); |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
732 if (lineno != NULL) { |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
733 offset = PySequence_GetItem(info, 2); |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
734 if (offset != NULL) { |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
735 text = PySequence_GetItem(info, 3); |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
736 if (text != NULL) { |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
737 status = |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
738 PyObject_SetAttrString(self, "filename", filename) |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
739 || PyObject_SetAttrString(self, "lineno", lineno) |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
740 || PyObject_SetAttrString(self, "offset", offset) |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
741 || PyObject_SetAttrString(self, "text", text); |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
742 Py_DECREF(text); |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
743 } |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
744 Py_DECREF(offset); |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
745 } |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
746 Py_DECREF(lineno); |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
747 } |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
748 Py_DECREF(filename); |
|
847844248c6f
SyntaxError__init__(): Be a little more robust when picking apart the
Fred Drake <fdrake@acm.org>
parents:
16837
diff
changeset
|
749 } |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
750 Py_DECREF(info); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
751 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
752 if (status) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
753 goto finally; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
754 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
755 Py_INCREF(Py_None); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
756 rtnval = Py_None; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
757 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
758 finally: |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
759 Py_DECREF(args); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
760 return rtnval; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
761 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
762 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
763 |
|
13996
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
764 /* This is called "my_basename" instead of just "basename" to avoid name |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
765 conflicts with glibc; basename is already prototyped if _GNU_SOURCE is |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
766 defined, and Python does define that. */ |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
767 static char * |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
768 my_basename(char *name) |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
769 { |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
770 char *cp = name; |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
771 char *result = name; |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
772 |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
773 if (name == NULL) |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
774 return "???"; |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
775 while (*cp != '\0') { |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
776 if (*cp == SEP) |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
777 result = cp + 1; |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
778 ++cp; |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
779 } |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
780 return result; |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
781 } |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
782 |
|
d8069efcd76e
my_basename(): Removes the leading path components from a path name,
Fred Drake <fdrake@acm.org>
parents:
13991
diff
changeset
|
783 |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
784 static PyObject * |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
785 SyntaxError__str__(PyObject *self, PyObject *args) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
786 { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
787 PyObject *msg; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
788 PyObject *str; |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
789 PyObject *filename, *lineno, *result; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
790 |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
791 if (!PyArg_ParseTuple(args, "O:__str__", &self)) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
792 return NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
793 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
794 if (!(msg = PyObject_GetAttrString(self, "msg"))) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
795 return NULL; |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
796 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
797 str = PyObject_Str(msg); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
798 Py_DECREF(msg); |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
799 result = str; |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
800 |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
801 /* XXX -- do all the additional formatting with filename and |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
802 lineno here */ |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
803 |
|
25110
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
804 if (str != NULL && PyString_Check(str)) { |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
805 int have_filename = 0; |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
806 int have_lineno = 0; |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
807 char *buffer = NULL; |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
808 |
|
14013
6c7fa523726f
SyntaxError__str__(): Fix two memory problems discovered by Insure.
Barry Warsaw <barry@python.org>
parents:
13996
diff
changeset
|
809 if ((filename = PyObject_GetAttrString(self, "filename")) != NULL) |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
810 have_filename = PyString_Check(filename); |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
811 else |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
812 PyErr_Clear(); |
|
14013
6c7fa523726f
SyntaxError__str__(): Fix two memory problems discovered by Insure.
Barry Warsaw <barry@python.org>
parents:
13996
diff
changeset
|
813 |
|
6c7fa523726f
SyntaxError__str__(): Fix two memory problems discovered by Insure.
Barry Warsaw <barry@python.org>
parents:
13996
diff
changeset
|
814 if ((lineno = PyObject_GetAttrString(self, "lineno")) != NULL) |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
815 have_lineno = PyInt_Check(lineno); |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
816 else |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
817 PyErr_Clear(); |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
818 |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
819 if (have_filename || have_lineno) { |
|
14013
6c7fa523726f
SyntaxError__str__(): Fix two memory problems discovered by Insure.
Barry Warsaw <barry@python.org>
parents:
13996
diff
changeset
|
820 int bufsize = PyString_GET_SIZE(str) + 64; |
|
6c7fa523726f
SyntaxError__str__(): Fix two memory problems discovered by Insure.
Barry Warsaw <barry@python.org>
parents:
13996
diff
changeset
|
821 if (have_filename) |
|
6c7fa523726f
SyntaxError__str__(): Fix two memory problems discovered by Insure.
Barry Warsaw <barry@python.org>
parents:
13996
diff
changeset
|
822 bufsize += PyString_GET_SIZE(filename); |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
823 |
|
21072
639c0a3ae8dc
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20279
diff
changeset
|
824 buffer = PyMem_MALLOC(bufsize); |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
825 if (buffer != NULL) { |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
826 if (have_filename && have_lineno) |
|
21072
639c0a3ae8dc
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20279
diff
changeset
|
827 PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)", |
|
639c0a3ae8dc
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20279
diff
changeset
|
828 PyString_AS_STRING(str), |
|
639c0a3ae8dc
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20279
diff
changeset
|
829 my_basename(PyString_AS_STRING(filename)), |
|
639c0a3ae8dc
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20279
diff
changeset
|
830 PyInt_AsLong(lineno)); |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
831 else if (have_filename) |
|
21072
639c0a3ae8dc
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20279
diff
changeset
|
832 PyOS_snprintf(buffer, bufsize, "%s (%s)", |
|
639c0a3ae8dc
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20279
diff
changeset
|
833 PyString_AS_STRING(str), |
|
639c0a3ae8dc
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20279
diff
changeset
|
834 my_basename(PyString_AS_STRING(filename))); |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
835 else if (have_lineno) |
|
21072
639c0a3ae8dc
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20279
diff
changeset
|
836 PyOS_snprintf(buffer, bufsize, "%s (line %ld)", |
|
639c0a3ae8dc
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20279
diff
changeset
|
837 PyString_AS_STRING(str), |
|
639c0a3ae8dc
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20279
diff
changeset
|
838 PyInt_AsLong(lineno)); |
|
14013
6c7fa523726f
SyntaxError__str__(): Fix two memory problems discovered by Insure.
Barry Warsaw <barry@python.org>
parents:
13996
diff
changeset
|
839 |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
840 result = PyString_FromString(buffer); |
|
14013
6c7fa523726f
SyntaxError__str__(): Fix two memory problems discovered by Insure.
Barry Warsaw <barry@python.org>
parents:
13996
diff
changeset
|
841 PyMem_FREE(buffer); |
|
6c7fa523726f
SyntaxError__str__(): Fix two memory problems discovered by Insure.
Barry Warsaw <barry@python.org>
parents:
13996
diff
changeset
|
842 |
|
13991
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
843 if (result == NULL) |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
844 result = str; |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
845 else |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
846 Py_DECREF(str); |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
847 } |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
848 } |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
849 Py_XDECREF(filename); |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
850 Py_XDECREF(lineno); |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
851 } |
|
7834a113ce24
SyntaxError__str__(): Do more formatting of the exception here, rather
Fred Drake <fdrake@acm.org>
parents:
13973
diff
changeset
|
852 return result; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
853 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
854 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
855 |
|
17518
f939ce52a734
Make some private symbols static.
Guido van Rossum <guido@python.org>
parents:
16852
diff
changeset
|
856 static PyMethodDef SyntaxError_methods[] = { |
|
13182
1e302d996d58
replace constant 1 with symbolic constant METH_VARARGS
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
12968
diff
changeset
|
857 {"__init__", SyntaxError__init__, METH_VARARGS}, |
|
1e302d996d58
replace constant 1 with symbolic constant METH_VARARGS
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
12968
diff
changeset
|
858 {"__str__", SyntaxError__str__, METH_VARARGS}, |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
859 {NULL, NULL} |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
860 }; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
861 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
862 |
|
25110
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
863 static PyObject * |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
864 KeyError__str__(PyObject *self, PyObject *args) |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
865 { |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
866 PyObject *argsattr; |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
867 PyObject *result; |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
868 |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
869 if (!PyArg_ParseTuple(args, "O:__str__", &self)) |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
870 return NULL; |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
871 |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
872 if (!(argsattr = PyObject_GetAttrString(self, "args"))) |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
873 return NULL; |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
874 |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
875 /* If args is a tuple of exactly one item, apply repr to args[0]. |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
876 This is done so that e.g. the exception raised by {}[''] prints |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
877 KeyError: '' |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
878 rather than the confusing |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
879 KeyError |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
880 alone. The downside is that if KeyError is raised with an explanatory |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
881 string, that string will be displayed in quotes. Too bad. |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
882 If args is anything else, use the default Exception__str__(). |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
883 */ |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
884 if (PyTuple_Check(argsattr) && PyTuple_GET_SIZE(argsattr) == 1) { |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
885 PyObject *key = PyTuple_GET_ITEM(argsattr, 0); |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
886 result = PyObject_Repr(key); |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
887 } |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
888 else |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
889 result = Exception__str__(self, args); |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
890 |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
891 Py_DECREF(argsattr); |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
892 return result; |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
893 } |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
894 |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
895 static PyMethodDef KeyError_methods[] = { |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
896 {"__str__", KeyError__str__, METH_VARARGS}, |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
897 {NULL, NULL} |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
898 }; |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
899 |
|
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
900 |
|
26318
910fa739f4a4
Fix PEP 293 related problems with --disable-unicode builds
Walter Dörwald <walter@livinglogic.de>
parents:
25325
diff
changeset
|
901 #ifdef Py_USING_UNICODE |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
902 static |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
903 int get_int(PyObject *exc, const char *name, int *value) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
904 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
905 PyObject *attr = PyObject_GetAttrString(exc, (char *)name); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
906 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
907 if (!attr) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
908 return -1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
909 if (!PyInt_Check(attr)) { |
|
25093
ae1469e468a0
Limit the length of attribute names in exception messages
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
910 PyErr_Format(PyExc_TypeError, "%.200s attribute must be int", name); |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
911 Py_DECREF(attr); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
912 return -1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
913 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
914 *value = PyInt_AS_LONG(attr); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
915 Py_DECREF(attr); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
916 return 0; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
917 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
918 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
919 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
920 static |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
921 int set_int(PyObject *exc, const char *name, int value) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
922 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
923 PyObject *obj = PyInt_FromLong(value); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
924 int result; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
925 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
926 if (!obj) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
927 return -1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
928 result = PyObject_SetAttrString(exc, (char *)name, obj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
929 Py_DECREF(obj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
930 return result; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
931 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
932 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
933 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
934 static |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
935 PyObject *get_string(PyObject *exc, const char *name) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
936 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
937 PyObject *attr = PyObject_GetAttrString(exc, (char *)name); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
938 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
939 if (!attr) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
940 return NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
941 if (!PyString_Check(attr)) { |
|
25093
ae1469e468a0
Limit the length of attribute names in exception messages
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
942 PyErr_Format(PyExc_TypeError, "%.200s attribute must be str", name); |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
943 Py_DECREF(attr); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
944 return NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
945 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
946 return attr; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
947 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
948 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
949 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
950 static |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
951 int set_string(PyObject *exc, const char *name, const char *value) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
952 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
953 PyObject *obj = PyString_FromString(value); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
954 int result; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
955 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
956 if (!obj) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
957 return -1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
958 result = PyObject_SetAttrString(exc, (char *)name, obj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
959 Py_DECREF(obj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
960 return result; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
961 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
962 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
963 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
964 static |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
965 PyObject *get_unicode(PyObject *exc, const char *name) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
966 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
967 PyObject *attr = PyObject_GetAttrString(exc, (char *)name); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
968 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
969 if (!attr) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
970 return NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
971 if (!PyUnicode_Check(attr)) { |
|
25093
ae1469e468a0
Limit the length of attribute names in exception messages
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
972 PyErr_Format(PyExc_TypeError, "%.200s attribute must be unicode", name); |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
973 Py_DECREF(attr); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
974 return NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
975 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
976 return attr; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
977 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
978 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
979 PyObject * PyUnicodeEncodeError_GetEncoding(PyObject *exc) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
980 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
981 return get_string(exc, "encoding"); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
982 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
983 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
984 PyObject * PyUnicodeDecodeError_GetEncoding(PyObject *exc) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
985 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
986 return get_string(exc, "encoding"); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
987 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
988 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
989 PyObject *PyUnicodeEncodeError_GetObject(PyObject *exc) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
990 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
991 return get_unicode(exc, "object"); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
992 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
993 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
994 PyObject *PyUnicodeDecodeError_GetObject(PyObject *exc) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
995 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
996 return get_string(exc, "object"); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
997 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
998 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
999 PyObject *PyUnicodeTranslateError_GetObject(PyObject *exc) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1000 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1001 return get_unicode(exc, "object"); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1002 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1003 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1004 int PyUnicodeEncodeError_GetStart(PyObject *exc, int *start) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1005 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1006 if (!get_int(exc, "start", start)) { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1007 PyObject *object = PyUnicodeEncodeError_GetObject(exc); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1008 int size; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1009 if (!object) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1010 return -1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1011 size = PyUnicode_GET_SIZE(object); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1012 if (*start<0) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1013 *start = 0; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1014 if (*start>=size) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1015 *start = size-1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1016 Py_DECREF(object); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1017 return 0; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1018 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1019 return -1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1020 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1021 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1022 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1023 int PyUnicodeDecodeError_GetStart(PyObject *exc, int *start) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1024 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1025 if (!get_int(exc, "start", start)) { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1026 PyObject *object = PyUnicodeDecodeError_GetObject(exc); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1027 int size; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1028 if (!object) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1029 return -1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1030 size = PyString_GET_SIZE(object); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1031 if (*start<0) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1032 *start = 0; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1033 if (*start>=size) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1034 *start = size-1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1035 Py_DECREF(object); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1036 return 0; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1037 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1038 return -1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1039 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1040 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1041 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1042 int PyUnicodeTranslateError_GetStart(PyObject *exc, int *start) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1043 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1044 return PyUnicodeEncodeError_GetStart(exc, start); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1045 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1046 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1047 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1048 int PyUnicodeEncodeError_SetStart(PyObject *exc, int start) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1049 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1050 return set_int(exc, "start", start); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1051 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1052 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1053 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1054 int PyUnicodeDecodeError_SetStart(PyObject *exc, int start) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1055 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1056 return set_int(exc, "start", start); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1057 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1058 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1059 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1060 int PyUnicodeTranslateError_SetStart(PyObject *exc, int start) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1061 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1062 return set_int(exc, "start", start); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1063 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1064 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1065 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1066 int PyUnicodeEncodeError_GetEnd(PyObject *exc, int *end) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1067 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1068 if (!get_int(exc, "end", end)) { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1069 PyObject *object = PyUnicodeEncodeError_GetObject(exc); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1070 int size; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1071 if (!object) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1072 return -1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1073 size = PyUnicode_GET_SIZE(object); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1074 if (*end<1) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1075 *end = 1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1076 if (*end>size) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1077 *end = size; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1078 Py_DECREF(object); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1079 return 0; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1080 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1081 return -1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1082 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1083 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1084 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1085 int PyUnicodeDecodeError_GetEnd(PyObject *exc, int *end) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1086 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1087 if (!get_int(exc, "end", end)) { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1088 PyObject *object = PyUnicodeDecodeError_GetObject(exc); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1089 int size; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1090 if (!object) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1091 return -1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1092 size = PyString_GET_SIZE(object); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1093 if (*end<1) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1094 *end = 1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1095 if (*end>size) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1096 *end = size; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1097 Py_DECREF(object); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1098 return 0; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1099 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1100 return -1; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1101 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1102 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1103 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1104 int PyUnicodeTranslateError_GetEnd(PyObject *exc, int *start) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1105 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1106 return PyUnicodeEncodeError_GetEnd(exc, start); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1107 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1108 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1109 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1110 int PyUnicodeEncodeError_SetEnd(PyObject *exc, int end) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1111 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1112 return set_int(exc, "end", end); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1113 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1114 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1115 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1116 int PyUnicodeDecodeError_SetEnd(PyObject *exc, int end) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1117 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1118 return set_int(exc, "end", end); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1119 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1120 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1121 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1122 int PyUnicodeTranslateError_SetEnd(PyObject *exc, int end) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1123 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1124 return set_int(exc, "end", end); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1125 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1126 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1127 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1128 PyObject *PyUnicodeEncodeError_GetReason(PyObject *exc) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1129 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1130 return get_string(exc, "reason"); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1131 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1132 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1133 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1134 PyObject *PyUnicodeDecodeError_GetReason(PyObject *exc) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1135 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1136 return get_string(exc, "reason"); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1137 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1138 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1139 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1140 PyObject *PyUnicodeTranslateError_GetReason(PyObject *exc) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1141 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1142 return get_string(exc, "reason"); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1143 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1144 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1145 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1146 int PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1147 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1148 return set_string(exc, "reason", reason); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1149 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1150 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1151 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1152 int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1153 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1154 return set_string(exc, "reason", reason); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1155 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1156 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1157 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1158 int PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1159 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1160 return set_string(exc, "reason", reason); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1161 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1162 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1163 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1164 static PyObject * |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1165 UnicodeError__init__(PyObject *self, PyObject *args, PyTypeObject *objecttype) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1166 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1167 PyObject *rtnval = NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1168 PyObject *encoding; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1169 PyObject *object; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1170 PyObject *start; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1171 PyObject *end; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1172 PyObject *reason; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1173 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1174 if (!(self = get_self(args))) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1175 return NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1176 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1177 if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1178 return NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1179 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1180 if (!PyArg_ParseTuple(args, "O!O!O!O!O!", |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1181 &PyString_Type, &encoding, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1182 objecttype, &object, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1183 &PyInt_Type, &start, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1184 &PyInt_Type, &end, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1185 &PyString_Type, &reason)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1186 return NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1187 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1188 if (PyObject_SetAttrString(self, "args", args)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1189 goto finally; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1190 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1191 if (PyObject_SetAttrString(self, "encoding", encoding)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1192 goto finally; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1193 if (PyObject_SetAttrString(self, "object", object)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1194 goto finally; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1195 if (PyObject_SetAttrString(self, "start", start)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1196 goto finally; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1197 if (PyObject_SetAttrString(self, "end", end)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1198 goto finally; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1199 if (PyObject_SetAttrString(self, "reason", reason)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1200 goto finally; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1201 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1202 Py_INCREF(Py_None); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1203 rtnval = Py_None; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1204 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1205 finally: |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1206 Py_DECREF(args); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1207 return rtnval; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1208 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1209 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1210 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1211 static PyObject * |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1212 UnicodeEncodeError__init__(PyObject *self, PyObject *args) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1213 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1214 return UnicodeError__init__(self, args, &PyUnicode_Type); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1215 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1216 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1217 static PyObject * |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1218 UnicodeEncodeError__str__(PyObject *self, PyObject *arg) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1219 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1220 PyObject *encodingObj = NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1221 PyObject *objectObj = NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1222 int length; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1223 int start; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1224 int end; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1225 PyObject *reasonObj = NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1226 char buffer[1000]; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1227 PyObject *result = NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1228 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1229 self = arg; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1230 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1231 if (!(encodingObj = PyUnicodeEncodeError_GetEncoding(self))) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1232 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1233 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1234 if (!(objectObj = PyUnicodeEncodeError_GetObject(self))) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1235 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1236 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1237 length = PyUnicode_GET_SIZE(objectObj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1238 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1239 if (PyUnicodeEncodeError_GetStart(self, &start)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1240 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1241 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1242 if (PyUnicodeEncodeError_GetEnd(self, &end)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1243 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1244 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1245 if (!(reasonObj = PyUnicodeEncodeError_GetReason(self))) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1246 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1247 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1248 if (end==start+1) { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1249 PyOS_snprintf(buffer, sizeof(buffer), |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1250 "'%.400s' codec can't encode character '\\u%x' in position %d: %.400s", |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1251 PyString_AS_STRING(encodingObj), |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1252 (int)PyUnicode_AS_UNICODE(objectObj)[start], |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1253 start, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1254 PyString_AS_STRING(reasonObj) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1255 ); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1256 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1257 else { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1258 PyOS_snprintf(buffer, sizeof(buffer), |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1259 "'%.400s' codec can't encode characters in position %d-%d: %.400s", |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1260 PyString_AS_STRING(encodingObj), |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1261 start, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1262 end-1, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1263 PyString_AS_STRING(reasonObj) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1264 ); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1265 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1266 result = PyString_FromString(buffer); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1267 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1268 error: |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1269 Py_XDECREF(reasonObj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1270 Py_XDECREF(objectObj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1271 Py_XDECREF(encodingObj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1272 return result; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1273 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1274 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1275 static PyMethodDef UnicodeEncodeError_methods[] = { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1276 {"__init__", UnicodeEncodeError__init__, METH_VARARGS}, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1277 {"__str__", UnicodeEncodeError__str__, METH_O}, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1278 {NULL, NULL} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1279 }; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1280 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1281 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1282 PyObject * PyUnicodeEncodeError_Create( |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1283 const char *encoding, const Py_UNICODE *object, int length, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1284 int start, int end, const char *reason) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1285 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1286 return PyObject_CallFunction(PyExc_UnicodeEncodeError, "su#iis", |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1287 encoding, object, length, start, end, reason); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1288 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1289 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1290 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1291 static PyObject * |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1292 UnicodeDecodeError__init__(PyObject *self, PyObject *args) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1293 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1294 return UnicodeError__init__(self, args, &PyString_Type); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1295 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1296 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1297 static PyObject * |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1298 UnicodeDecodeError__str__(PyObject *self, PyObject *arg) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1299 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1300 PyObject *encodingObj = NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1301 PyObject *objectObj = NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1302 int length; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1303 int start; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1304 int end; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1305 PyObject *reasonObj = NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1306 char buffer[1000]; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1307 PyObject *result = NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1308 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1309 self = arg; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1310 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1311 if (!(encodingObj = PyUnicodeDecodeError_GetEncoding(self))) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1312 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1313 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1314 if (!(objectObj = PyUnicodeDecodeError_GetObject(self))) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1315 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1316 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1317 length = PyString_GET_SIZE(objectObj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1318 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1319 if (PyUnicodeDecodeError_GetStart(self, &start)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1320 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1321 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1322 if (PyUnicodeDecodeError_GetEnd(self, &end)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1323 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1324 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1325 if (!(reasonObj = PyUnicodeDecodeError_GetReason(self))) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1326 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1327 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1328 if (end==start+1) { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1329 PyOS_snprintf(buffer, sizeof(buffer), |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1330 "'%.400s' codec can't decode byte 0x%x in position %d: %.400s", |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1331 PyString_AS_STRING(encodingObj), |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1332 ((int)PyString_AS_STRING(objectObj)[start])&0xff, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1333 start, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1334 PyString_AS_STRING(reasonObj) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1335 ); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1336 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1337 else { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1338 PyOS_snprintf(buffer, sizeof(buffer), |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1339 "'%.400s' codec can't decode bytes in position %d-%d: %.400s", |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1340 PyString_AS_STRING(encodingObj), |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1341 start, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1342 end-1, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1343 PyString_AS_STRING(reasonObj) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1344 ); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1345 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1346 result = PyString_FromString(buffer); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1347 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1348 error: |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1349 Py_XDECREF(reasonObj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1350 Py_XDECREF(objectObj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1351 Py_XDECREF(encodingObj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1352 return result; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1353 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1354 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1355 static PyMethodDef UnicodeDecodeError_methods[] = { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1356 {"__init__", UnicodeDecodeError__init__, METH_VARARGS}, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1357 {"__str__", UnicodeDecodeError__str__, METH_O}, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1358 {NULL, NULL} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1359 }; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1360 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1361 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1362 PyObject * PyUnicodeDecodeError_Create( |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1363 const char *encoding, const char *object, int length, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1364 int start, int end, const char *reason) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1365 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1366 return PyObject_CallFunction(PyExc_UnicodeDecodeError, "ss#iis", |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1367 encoding, object, length, start, end, reason); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1368 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1369 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1370 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1371 static PyObject * |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1372 UnicodeTranslateError__init__(PyObject *self, PyObject *args) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1373 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1374 PyObject *rtnval = NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1375 PyObject *object; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1376 PyObject *start; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1377 PyObject *end; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1378 PyObject *reason; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1379 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1380 if (!(self = get_self(args))) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1381 return NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1382 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1383 if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1384 return NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1385 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1386 if (!PyArg_ParseTuple(args, "O!O!O!O!", |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1387 &PyUnicode_Type, &object, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1388 &PyInt_Type, &start, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1389 &PyInt_Type, &end, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1390 &PyString_Type, &reason)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1391 goto finally; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1392 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1393 if (PyObject_SetAttrString(self, "args", args)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1394 goto finally; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1395 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1396 if (PyObject_SetAttrString(self, "object", object)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1397 goto finally; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1398 if (PyObject_SetAttrString(self, "start", start)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1399 goto finally; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1400 if (PyObject_SetAttrString(self, "end", end)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1401 goto finally; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1402 if (PyObject_SetAttrString(self, "reason", reason)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1403 goto finally; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1404 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1405 Py_INCREF(Py_None); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1406 rtnval = Py_None; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1407 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1408 finally: |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1409 Py_DECREF(args); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1410 return rtnval; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1411 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1412 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1413 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1414 static PyObject * |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1415 UnicodeTranslateError__str__(PyObject *self, PyObject *arg) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1416 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1417 PyObject *objectObj = NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1418 int length; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1419 int start; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1420 int end; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1421 PyObject *reasonObj = NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1422 char buffer[1000]; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1423 PyObject *result = NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1424 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1425 self = arg; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1426 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1427 if (!(objectObj = PyUnicodeTranslateError_GetObject(self))) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1428 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1429 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1430 length = PyUnicode_GET_SIZE(objectObj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1431 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1432 if (PyUnicodeTranslateError_GetStart(self, &start)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1433 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1434 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1435 if (PyUnicodeTranslateError_GetEnd(self, &end)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1436 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1437 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1438 if (!(reasonObj = PyUnicodeTranslateError_GetReason(self))) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1439 goto error; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1440 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1441 if (end==start+1) { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1442 PyOS_snprintf(buffer, sizeof(buffer), |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1443 "can't translate character '\\u%x' in position %d: %.400s", |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1444 (int)PyUnicode_AS_UNICODE(objectObj)[start], |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1445 start, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1446 PyString_AS_STRING(reasonObj) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1447 ); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1448 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1449 else { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1450 PyOS_snprintf(buffer, sizeof(buffer), |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1451 "can't translate characters in position %d-%d: %.400s", |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1452 start, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1453 end-1, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1454 PyString_AS_STRING(reasonObj) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1455 ); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1456 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1457 result = PyString_FromString(buffer); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1458 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1459 error: |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1460 Py_XDECREF(reasonObj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1461 Py_XDECREF(objectObj); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1462 return result; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1463 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1464 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1465 static PyMethodDef UnicodeTranslateError_methods[] = { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1466 {"__init__", UnicodeTranslateError__init__, METH_VARARGS}, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1467 {"__str__", UnicodeTranslateError__str__, METH_O}, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1468 {NULL, NULL} |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1469 }; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1470 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1471 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1472 PyObject * PyUnicodeTranslateError_Create( |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1473 const Py_UNICODE *object, int length, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1474 int start, int end, const char *reason) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1475 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1476 return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#iis", |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1477 object, length, start, end, reason); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1478 } |
|
26318
910fa739f4a4
Fix PEP 293 related problems with --disable-unicode builds
Walter Dörwald <walter@livinglogic.de>
parents:
25325
diff
changeset
|
1479 #endif |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1480 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1481 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1482 |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1483 /* Exception doc strings */ |
|
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1484 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1485 PyDoc_STRVAR(AssertionError__doc__, "Assertion failed."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1486 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1487 PyDoc_STRVAR(LookupError__doc__, "Base class for lookup errors."); |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1488 |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1489 PyDoc_STRVAR(IndexError__doc__, "Sequence index out of range."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1490 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1491 PyDoc_STRVAR(KeyError__doc__, "Mapping key not found."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1492 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1493 PyDoc_STRVAR(ArithmeticError__doc__, "Base class for arithmetic errors."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1494 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1495 PyDoc_STRVAR(OverflowError__doc__, "Result too large to be represented."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1496 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1497 PyDoc_STRVAR(ZeroDivisionError__doc__, |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1498 "Second argument to a division or modulo operation was zero."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1499 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1500 PyDoc_STRVAR(FloatingPointError__doc__, "Floating point operation failed."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1501 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1502 PyDoc_STRVAR(ValueError__doc__, |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1503 "Inappropriate argument value (of correct type)."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1504 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1505 PyDoc_STRVAR(UnicodeError__doc__, "Unicode related error."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1506 |
|
26318
910fa739f4a4
Fix PEP 293 related problems with --disable-unicode builds
Walter Dörwald <walter@livinglogic.de>
parents:
25325
diff
changeset
|
1507 #ifdef Py_USING_UNICODE |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1508 PyDoc_STRVAR(UnicodeEncodeError__doc__, "Unicode encoding error."); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1509 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1510 PyDoc_STRVAR(UnicodeDecodeError__doc__, "Unicode decoding error."); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1511 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1512 PyDoc_STRVAR(UnicodeTranslateError__doc__, "Unicode translation error."); |
|
26318
910fa739f4a4
Fix PEP 293 related problems with --disable-unicode builds
Walter Dörwald <walter@livinglogic.de>
parents:
25325
diff
changeset
|
1513 #endif |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1514 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1515 PyDoc_STRVAR(SystemError__doc__, |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1516 "Internal error in the Python interpreter.\n\ |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1517 \n\ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1518 Please report this to the Python maintainer, along with the traceback,\n\ |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1519 the Python version, and the hardware/OS platform and version."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1520 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1521 PyDoc_STRVAR(ReferenceError__doc__, |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1522 "Weak ref proxy used after referent went away."); |
|
20279
8b3ea7335c1b
weakref.ReferenceError becomes a built-in exception now that weak ref objects
Fred Drake <fdrake@acm.org>
parents:
19433
diff
changeset
|
1523 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1524 PyDoc_STRVAR(MemoryError__doc__, "Out of memory."); |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1525 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1526 PyDoc_STRVAR(IndentationError__doc__, "Improper indentation."); |
|
13539
feab677269e0
Create two new exceptions: IndentationError and TabError. These are
Fred Drake <fdrake@acm.org>
parents:
13484
diff
changeset
|
1527 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1528 PyDoc_STRVAR(TabError__doc__, "Improper mixture of spaces and tabs."); |
|
13539
feab677269e0
Create two new exceptions: IndentationError and TabError. These are
Fred Drake <fdrake@acm.org>
parents:
13484
diff
changeset
|
1529 |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1530 /* Warning category docstrings */ |
|
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1531 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1532 PyDoc_STRVAR(Warning__doc__, "Base class for warning categories."); |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1533 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1534 PyDoc_STRVAR(UserWarning__doc__, |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1535 "Base class for warnings generated by user code."); |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1536 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1537 PyDoc_STRVAR(DeprecationWarning__doc__, |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1538 "Base class for warnings about deprecated features."); |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1539 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1540 PyDoc_STRVAR(PendingDeprecationWarning__doc__, |
|
23564
3f242cdd0904
As discussed on python-dev, add a mechanism to indicate features
Neal Norwitz <nnorwitz@gmail.com>
parents:
22629
diff
changeset
|
1541 "Base class for warnings about features which will be deprecated " |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1542 "in the future."); |
|
23564
3f242cdd0904
As discussed on python-dev, add a mechanism to indicate features
Neal Norwitz <nnorwitz@gmail.com>
parents:
22629
diff
changeset
|
1543 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1544 PyDoc_STRVAR(SyntaxWarning__doc__, |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1545 "Base class for warnings about dubious syntax."); |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1546 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1547 PyDoc_STRVAR(OverflowWarning__doc__, |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1548 "Base class for warnings about numeric overflow."); |
|
19433
5d81c6bff306
Introduce OverflowWarning -- to be issued when short int operations
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
1549 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1550 PyDoc_STRVAR(RuntimeWarning__doc__, |
|
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
23564
diff
changeset
|
1551 "Base class for warnings about dubious runtime behavior."); |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1552 |
|
24818
31d2860089e6
Added a FutureWarning for constructs that will change semantically in
Barry Warsaw <barry@python.org>
parents:
24420
diff
changeset
|
1553 PyDoc_STRVAR(FutureWarning__doc__, |
|
31d2860089e6
Added a FutureWarning for constructs that will change semantically in
Barry Warsaw <barry@python.org>
parents:
24420
diff
changeset
|
1554 "Base class for warnings about constructs that will change semantically " |
|
31d2860089e6
Added a FutureWarning for constructs that will change semantically in
Barry Warsaw <barry@python.org>
parents:
24420
diff
changeset
|
1555 "in the future."); |
|
31d2860089e6
Added a FutureWarning for constructs that will change semantically in
Barry Warsaw <barry@python.org>
parents:
24420
diff
changeset
|
1556 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1557 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1558 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1559 /* module global functions */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1560 static PyMethodDef functions[] = { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1561 /* Sentinel */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1562 {NULL, NULL} |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1563 }; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1564 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1565 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1566 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1567 /* Global C API defined exceptions */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1568 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1569 PyObject *PyExc_Exception; |
|
17597
32e7d0898eab
Iterators phase 1. This comprises:
Guido van Rossum <guido@python.org>
parents:
17518
diff
changeset
|
1570 PyObject *PyExc_StopIteration; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1571 PyObject *PyExc_StandardError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1572 PyObject *PyExc_ArithmeticError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1573 PyObject *PyExc_LookupError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1574 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1575 PyObject *PyExc_AssertionError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1576 PyObject *PyExc_AttributeError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1577 PyObject *PyExc_EOFError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1578 PyObject *PyExc_FloatingPointError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1579 PyObject *PyExc_EnvironmentError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1580 PyObject *PyExc_IOError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1581 PyObject *PyExc_OSError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1582 PyObject *PyExc_ImportError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1583 PyObject *PyExc_IndexError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1584 PyObject *PyExc_KeyError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1585 PyObject *PyExc_KeyboardInterrupt; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1586 PyObject *PyExc_MemoryError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1587 PyObject *PyExc_NameError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1588 PyObject *PyExc_OverflowError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1589 PyObject *PyExc_RuntimeError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1590 PyObject *PyExc_NotImplementedError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1591 PyObject *PyExc_SyntaxError; |
|
13539
feab677269e0
Create two new exceptions: IndentationError and TabError. These are
Fred Drake <fdrake@acm.org>
parents:
13484
diff
changeset
|
1592 PyObject *PyExc_IndentationError; |
|
feab677269e0
Create two new exceptions: IndentationError and TabError. These are
Fred Drake <fdrake@acm.org>
parents:
13484
diff
changeset
|
1593 PyObject *PyExc_TabError; |
|
20279
8b3ea7335c1b
weakref.ReferenceError becomes a built-in exception now that weak ref objects
Fred Drake <fdrake@acm.org>
parents:
19433
diff
changeset
|
1594 PyObject *PyExc_ReferenceError; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1595 PyObject *PyExc_SystemError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1596 PyObject *PyExc_SystemExit; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1597 PyObject *PyExc_UnboundLocalError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1598 PyObject *PyExc_UnicodeError; |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1599 PyObject *PyExc_UnicodeEncodeError; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1600 PyObject *PyExc_UnicodeDecodeError; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1601 PyObject *PyExc_UnicodeTranslateError; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1602 PyObject *PyExc_TypeError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1603 PyObject *PyExc_ValueError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1604 PyObject *PyExc_ZeroDivisionError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1605 #ifdef MS_WINDOWS |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1606 PyObject *PyExc_WindowsError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1607 #endif |
|
26550
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
26318
diff
changeset
|
1608 #ifdef __VMS |
|
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
26318
diff
changeset
|
1609 PyObject *PyExc_VMSError; |
|
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
26318
diff
changeset
|
1610 #endif |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1611 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1612 /* Pre-computed MemoryError instance. Best to create this as early as |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1613 * possibly and not wait until a MemoryError is actually raised! |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1614 */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1615 PyObject *PyExc_MemoryErrorInst; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1616 |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1617 /* Predefined warning categories */ |
|
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1618 PyObject *PyExc_Warning; |
|
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1619 PyObject *PyExc_UserWarning; |
|
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1620 PyObject *PyExc_DeprecationWarning; |
|
23564
3f242cdd0904
As discussed on python-dev, add a mechanism to indicate features
Neal Norwitz <nnorwitz@gmail.com>
parents:
22629
diff
changeset
|
1621 PyObject *PyExc_PendingDeprecationWarning; |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1622 PyObject *PyExc_SyntaxWarning; |
|
19433
5d81c6bff306
Introduce OverflowWarning -- to be issued when short int operations
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
1623 PyObject *PyExc_OverflowWarning; |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1624 PyObject *PyExc_RuntimeWarning; |
|
24818
31d2860089e6
Added a FutureWarning for constructs that will change semantically in
Barry Warsaw <barry@python.org>
parents:
24420
diff
changeset
|
1625 PyObject *PyExc_FutureWarning; |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1626 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1627 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1628 |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
1629 /* mapping between exception names and their PyObject ** */ |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
1630 static struct { |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
1631 char *name; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
1632 PyObject **exc; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
1633 PyObject **base; /* NULL == PyExc_StandardError */ |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
1634 char *docstr; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
1635 PyMethodDef *methods; |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
1636 int (*classinit)(PyObject *); |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
1637 } exctable[] = { |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1638 /* |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1639 * The first three classes MUST appear in exactly this order |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1640 */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1641 {"Exception", &PyExc_Exception}, |
|
17597
32e7d0898eab
Iterators phase 1. This comprises:
Guido van Rossum <guido@python.org>
parents:
17518
diff
changeset
|
1642 {"StopIteration", &PyExc_StopIteration, &PyExc_Exception, |
|
32e7d0898eab
Iterators phase 1. This comprises:
Guido van Rossum <guido@python.org>
parents:
17518
diff
changeset
|
1643 StopIteration__doc__}, |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1644 {"StandardError", &PyExc_StandardError, &PyExc_Exception, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1645 StandardError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1646 {"TypeError", &PyExc_TypeError, 0, TypeError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1647 /* |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1648 * The rest appear in depth-first order of the hierarchy |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1649 */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1650 {"SystemExit", &PyExc_SystemExit, &PyExc_Exception, SystemExit__doc__, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1651 SystemExit_methods}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1652 {"KeyboardInterrupt", &PyExc_KeyboardInterrupt, 0, KeyboardInterrupt__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1653 {"ImportError", &PyExc_ImportError, 0, ImportError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1654 {"EnvironmentError", &PyExc_EnvironmentError, 0, EnvironmentError__doc__, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1655 EnvironmentError_methods}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1656 {"IOError", &PyExc_IOError, &PyExc_EnvironmentError, IOError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1657 {"OSError", &PyExc_OSError, &PyExc_EnvironmentError, OSError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1658 #ifdef MS_WINDOWS |
|
13973
4e28ca345cfe
Fix the parent of WindowsError - both the comments in this source file, and the previous exceptions.py have WindowsError as a sub-class of OSError.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13657
diff
changeset
|
1659 {"WindowsError", &PyExc_WindowsError, &PyExc_OSError, |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1660 WindowsError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1661 #endif /* MS_WINDOWS */ |
|
26550
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
26318
diff
changeset
|
1662 #ifdef __VMS |
|
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
26318
diff
changeset
|
1663 {"VMSError", &PyExc_VMSError, &PyExc_OSError, |
|
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
26318
diff
changeset
|
1664 VMSError__doc__}, |
|
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
26318
diff
changeset
|
1665 #endif |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1666 {"EOFError", &PyExc_EOFError, 0, EOFError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1667 {"RuntimeError", &PyExc_RuntimeError, 0, RuntimeError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1668 {"NotImplementedError", &PyExc_NotImplementedError, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1669 &PyExc_RuntimeError, NotImplementedError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1670 {"NameError", &PyExc_NameError, 0, NameError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1671 {"UnboundLocalError", &PyExc_UnboundLocalError, &PyExc_NameError, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1672 UnboundLocalError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1673 {"AttributeError", &PyExc_AttributeError, 0, AttributeError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1674 {"SyntaxError", &PyExc_SyntaxError, 0, SyntaxError__doc__, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1675 SyntaxError_methods, SyntaxError__classinit__}, |
|
13539
feab677269e0
Create two new exceptions: IndentationError and TabError. These are
Fred Drake <fdrake@acm.org>
parents:
13484
diff
changeset
|
1676 {"IndentationError", &PyExc_IndentationError, &PyExc_SyntaxError, |
|
feab677269e0
Create two new exceptions: IndentationError and TabError. These are
Fred Drake <fdrake@acm.org>
parents:
13484
diff
changeset
|
1677 IndentationError__doc__}, |
|
feab677269e0
Create two new exceptions: IndentationError and TabError. These are
Fred Drake <fdrake@acm.org>
parents:
13484
diff
changeset
|
1678 {"TabError", &PyExc_TabError, &PyExc_IndentationError, |
|
feab677269e0
Create two new exceptions: IndentationError and TabError. These are
Fred Drake <fdrake@acm.org>
parents:
13484
diff
changeset
|
1679 TabError__doc__}, |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1680 {"AssertionError", &PyExc_AssertionError, 0, AssertionError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1681 {"LookupError", &PyExc_LookupError, 0, LookupError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1682 {"IndexError", &PyExc_IndexError, &PyExc_LookupError, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1683 IndexError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1684 {"KeyError", &PyExc_KeyError, &PyExc_LookupError, |
|
25110
0401a0ead1eb
Add a custom __str__ method to KeyError that applies repr() to the
Guido van Rossum <guido@python.org>
parents:
25094
diff
changeset
|
1685 KeyError__doc__, KeyError_methods}, |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1686 {"ArithmeticError", &PyExc_ArithmeticError, 0, ArithmeticError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1687 {"OverflowError", &PyExc_OverflowError, &PyExc_ArithmeticError, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1688 OverflowError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1689 {"ZeroDivisionError", &PyExc_ZeroDivisionError, &PyExc_ArithmeticError, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1690 ZeroDivisionError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1691 {"FloatingPointError", &PyExc_FloatingPointError, &PyExc_ArithmeticError, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1692 FloatingPointError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1693 {"ValueError", &PyExc_ValueError, 0, ValueError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1694 {"UnicodeError", &PyExc_UnicodeError, &PyExc_ValueError, UnicodeError__doc__}, |
|
26318
910fa739f4a4
Fix PEP 293 related problems with --disable-unicode builds
Walter Dörwald <walter@livinglogic.de>
parents:
25325
diff
changeset
|
1695 #ifdef Py_USING_UNICODE |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1696 {"UnicodeEncodeError", &PyExc_UnicodeEncodeError, &PyExc_UnicodeError, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1697 UnicodeEncodeError__doc__, UnicodeEncodeError_methods}, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1698 {"UnicodeDecodeError", &PyExc_UnicodeDecodeError, &PyExc_UnicodeError, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1699 UnicodeDecodeError__doc__, UnicodeDecodeError_methods}, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1700 {"UnicodeTranslateError", &PyExc_UnicodeTranslateError, &PyExc_UnicodeError, |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24818
diff
changeset
|
1701 UnicodeTranslateError__doc__, UnicodeTranslateError_methods}, |
|
26318
910fa739f4a4
Fix PEP 293 related problems with --disable-unicode builds
Walter Dörwald <walter@livinglogic.de>
parents:
25325
diff
changeset
|
1702 #endif |
|
20279
8b3ea7335c1b
weakref.ReferenceError becomes a built-in exception now that weak ref objects
Fred Drake <fdrake@acm.org>
parents:
19433
diff
changeset
|
1703 {"ReferenceError", &PyExc_ReferenceError, 0, ReferenceError__doc__}, |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1704 {"SystemError", &PyExc_SystemError, 0, SystemError__doc__}, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1705 {"MemoryError", &PyExc_MemoryError, 0, MemoryError__doc__}, |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1706 /* Warning categories */ |
|
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1707 {"Warning", &PyExc_Warning, &PyExc_Exception, Warning__doc__}, |
|
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1708 {"UserWarning", &PyExc_UserWarning, &PyExc_Warning, UserWarning__doc__}, |
|
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1709 {"DeprecationWarning", &PyExc_DeprecationWarning, &PyExc_Warning, |
|
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1710 DeprecationWarning__doc__}, |
|
23564
3f242cdd0904
As discussed on python-dev, add a mechanism to indicate features
Neal Norwitz <nnorwitz@gmail.com>
parents:
22629
diff
changeset
|
1711 {"PendingDeprecationWarning", &PyExc_PendingDeprecationWarning, &PyExc_Warning, |
|
3f242cdd0904
As discussed on python-dev, add a mechanism to indicate features
Neal Norwitz <nnorwitz@gmail.com>
parents:
22629
diff
changeset
|
1712 PendingDeprecationWarning__doc__}, |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1713 {"SyntaxWarning", &PyExc_SyntaxWarning, &PyExc_Warning, SyntaxWarning__doc__}, |
|
19433
5d81c6bff306
Introduce OverflowWarning -- to be issued when short int operations
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
1714 {"OverflowWarning", &PyExc_OverflowWarning, &PyExc_Warning, |
|
5d81c6bff306
Introduce OverflowWarning -- to be issued when short int operations
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
1715 OverflowWarning__doc__}, |
|
15590
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1716 {"RuntimeWarning", &PyExc_RuntimeWarning, &PyExc_Warning, |
|
1e756f93bf5d
Add definitions for standard warning category classes (PyExc_Warning
Guido van Rossum <guido@python.org>
parents:
15318
diff
changeset
|
1717 RuntimeWarning__doc__}, |
|
24818
31d2860089e6
Added a FutureWarning for constructs that will change semantically in
Barry Warsaw <barry@python.org>
parents:
24420
diff
changeset
|
1718 {"FutureWarning", &PyExc_FutureWarning, &PyExc_Warning, |
|
31d2860089e6
Added a FutureWarning for constructs that will change semantically in
Barry Warsaw <barry@python.org>
parents:
24420
diff
changeset
|
1719 FutureWarning__doc__}, |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1720 /* Sentinel */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1721 {NULL} |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1722 }; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1723 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1724 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1725 |
|
24420
36e2fd3f08f7
Excise DL_IMPORT/EXPORT from object.h, and related files. This patch
Mark Hammond <mhammond@skippinet.com.au>
parents:
23832
diff
changeset
|
1726 void |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1727 _PyExc_Init(void) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1728 { |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
1729 char *modulename = "exceptions"; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1730 int modnamesz = strlen(modulename); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1731 int i; |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1732 PyObject *me, *mydict, *bltinmod, *bdict, *doc, *args; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1733 |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1734 me = Py_InitModule(modulename, functions); |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1735 if (me == NULL) |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1736 goto err; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1737 mydict = PyModule_GetDict(me); |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1738 if (mydict == NULL) |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1739 goto err; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1740 bltinmod = PyImport_ImportModule("__builtin__"); |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1741 if (bltinmod == NULL) |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1742 goto err; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1743 bdict = PyModule_GetDict(bltinmod); |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1744 if (bdict == NULL) |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1745 goto err; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1746 doc = PyString_FromString(module__doc__); |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1747 if (doc == NULL) |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1748 goto err; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1749 |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1750 i = PyDict_SetItemString(mydict, "__doc__", doc); |
|
13283
3e07a7315af5
init_exceptions(): Decref `doc' so it doesn't leak.
Barry Warsaw <barry@python.org>
parents:
13182
diff
changeset
|
1751 Py_DECREF(doc); |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1752 if (i < 0) { |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1753 err: |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1754 Py_FatalError("exceptions bootstrapping error."); |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1755 return; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1756 } |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1757 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1758 /* This is the base class of all exceptions, so make it first. */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1759 if (make_Exception(modulename) || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1760 PyDict_SetItemString(mydict, "Exception", PyExc_Exception) || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1761 PyDict_SetItemString(bdict, "Exception", PyExc_Exception)) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1762 { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1763 Py_FatalError("Base class `Exception' could not be created."); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1764 } |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
1765 |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1766 /* Now we can programmatically create all the remaining exceptions. |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1767 * Remember to start the loop at 1 to skip Exceptions. |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1768 */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1769 for (i=1; exctable[i].name; i++) { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1770 int status; |
|
13657
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
1771 char *cname = PyMem_NEW(char, modnamesz+strlen(exctable[i].name)+2); |
|
6a5314a6c2c2
Fix two instances of empty argument lists, and fix style
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
1772 PyObject *base; |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1773 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1774 (void)strcpy(cname, modulename); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1775 (void)strcat(cname, "."); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1776 (void)strcat(cname, exctable[i].name); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1777 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1778 if (exctable[i].base == 0) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1779 base = PyExc_StandardError; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1780 else |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1781 base = *exctable[i].base; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1782 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1783 status = make_class(exctable[i].exc, base, cname, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1784 exctable[i].methods, |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1785 exctable[i].docstr); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1786 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1787 PyMem_DEL(cname); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1788 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1789 if (status) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1790 Py_FatalError("Standard exception classes could not be created."); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1791 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1792 if (exctable[i].classinit) { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1793 status = (*exctable[i].classinit)(*exctable[i].exc); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1794 if (status) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1795 Py_FatalError("An exception class could not be initialized."); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1796 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1797 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1798 /* Now insert the class into both this module and the __builtin__ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1799 * module. |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1800 */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1801 if (PyDict_SetItemString(mydict, exctable[i].name, *exctable[i].exc) || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1802 PyDict_SetItemString(bdict, exctable[i].name, *exctable[i].exc)) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1803 { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1804 Py_FatalError("Module dictionary insertion problem."); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1805 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1806 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1807 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1808 /* Now we need to pre-allocate a MemoryError instance */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1809 args = Py_BuildValue("()"); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1810 if (!args || |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1811 !(PyExc_MemoryErrorInst = PyEval_CallObject(PyExc_MemoryError, args))) |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1812 { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1813 Py_FatalError("Cannot pre-allocate MemoryError instance\n"); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1814 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1815 Py_DECREF(args); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1816 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1817 /* We're done with __builtin__ */ |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1818 Py_DECREF(bltinmod); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1819 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1820 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1821 |
|
24420
36e2fd3f08f7
Excise DL_IMPORT/EXPORT from object.h, and related files. This patch
Mark Hammond <mhammond@skippinet.com.au>
parents:
23832
diff
changeset
|
1822 void |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17597
diff
changeset
|
1823 _PyExc_Fini(void) |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1824 { |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1825 int i; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1826 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1827 Py_XDECREF(PyExc_MemoryErrorInst); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1828 PyExc_MemoryErrorInst = NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1829 |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1830 for (i=0; exctable[i].name; i++) { |
|
16164
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
1831 /* clear the class's dictionary, freeing up circular references |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
1832 * between the class and its methods. |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
1833 */ |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
1834 PyObject* cdict = PyObject_GetAttrString(*exctable[i].exc, "__dict__"); |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
1835 PyDict_Clear(cdict); |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
1836 Py_DECREF(cdict); |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
1837 |
|
2208a03d05a3
Leak pluggin', bug fixin' and better documentin'. Specifically,
Barry Warsaw <barry@python.org>
parents:
15590
diff
changeset
|
1838 /* Now decref the exception class */ |
|
12771
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1839 Py_XDECREF(*exctable[i].exc); |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1840 *exctable[i].exc = NULL; |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1841 } |
|
52c6ac2d16a8
The standard exception classes. Moved here from ../Modules/_exceptions.c
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
1842 } |
