summaryrefslogtreecommitdiffstats
path: root/Python/errors.c
Commit message (Collapse)AuthorAgeFilesLines
* Merged revisions ↵Georg Brandl2009-04-051-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 71058,71149-71150,71212,71214-71216,71222,71225,71234,71237-71238,71240-71241,71243,71249,71251 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r71058 | georg.brandl | 2009-04-02 20:09:04 +0200 (Do, 02 Apr 2009) | 3 lines PyErr_NormalizeException may not set an error, so convert the PyErr_SetObject call on hitting the recursion limit into just assigning it to the arguments provided. ........ r71149 | georg.brandl | 2009-04-04 15:42:39 +0200 (Sa, 04 Apr 2009) | 1 line #5642: clarify map() compatibility to the builtin. ........ r71150 | georg.brandl | 2009-04-04 15:45:49 +0200 (Sa, 04 Apr 2009) | 1 line #5601: clarify that webbrowser is not meant for file names. ........ r71212 | georg.brandl | 2009-04-05 12:24:20 +0200 (So, 05 Apr 2009) | 1 line #1742837: expand HTTP server docs, and fix SocketServer ones to document methods as methods, not functions. ........ r71214 | georg.brandl | 2009-04-05 12:29:57 +0200 (So, 05 Apr 2009) | 1 line Normalize spelling of Mac OS X. ........ r71215 | georg.brandl | 2009-04-05 12:32:26 +0200 (So, 05 Apr 2009) | 1 line Avoid sure signs of a diseased mind. ........ r71216 | georg.brandl | 2009-04-05 12:41:02 +0200 (So, 05 Apr 2009) | 1 line #1718017: document the relation of os.path and the posixpath, ntpath etc. modules better. ........ r71222 | georg.brandl | 2009-04-05 13:07:14 +0200 (So, 05 Apr 2009) | 1 line #5615: make it possible to configure --without-threads again. ........ r71225 | georg.brandl | 2009-04-05 13:54:07 +0200 (So, 05 Apr 2009) | 1 line #5580: no need to use parentheses when converterr() argument is actually a type description. ........ r71234 | georg.brandl | 2009-04-05 15:16:35 +0200 (So, 05 Apr 2009) | 1 line Whitespace normalization. ........ r71237 | georg.brandl | 2009-04-05 16:24:52 +0200 (So, 05 Apr 2009) | 1 line #1326077: fix traceback formatting of SyntaxErrors. This fixes two differences with formatting coming from Python: a) the reproduction of location details in the error message if no line text is given, b) the prefixing of the last line by one space. ........ r71238 | georg.brandl | 2009-04-05 16:25:41 +0200 (So, 05 Apr 2009) | 1 line Add NEWS entry for r71237. ........ r71240 | georg.brandl | 2009-04-05 16:40:06 +0200 (So, 05 Apr 2009) | 1 line #5370: doc update about unpickling objects with custom __getattr__ etc. methods. ........ r71241 | georg.brandl | 2009-04-05 16:48:49 +0200 (So, 05 Apr 2009) | 1 line #5471: fix expanduser() for $HOME set to "/". ........ r71243 | georg.brandl | 2009-04-05 17:14:29 +0200 (So, 05 Apr 2009) | 1 line #5432: make plistlib docstring a raw string, since it contains examples with backslash escapes. ........ r71249 | georg.brandl | 2009-04-05 18:30:43 +0200 (So, 05 Apr 2009) | 1 line #5444: adapt make.bat to new htmlhelp output file name. ........ r71251 | georg.brandl | 2009-04-05 19:17:42 +0200 (So, 05 Apr 2009) | 1 line #5298: clarify docs about GIL by using more consistent wording. ........
* Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as toAntoine Pitrou2008-08-261-1/+0
| | | | | | | | | | match Python 2.5 speed despite the __instancecheck__ / __subclasscheck__ mechanism. In the process, fix a bug where isinstance() and issubclass(), when given a tuple of classes as second argument, were looking up __instancecheck__ / __subclasscheck__ on the tuple rather than on each type object. Reviewed by Benjamin Peterson and Raymond Hettinger.
* #2542: now that issubclass() may call arbitrary code,Amaury Forgeot d'Arc2008-07-311-3/+12
| | | | make sure that PyErr_ExceptionMatches returns 0 when an exception occurs there.
* This reverts r63675 based on the discussion in this thread:Gregory P. Smith2008-06-091-9/+9
| | | | | | | http://mail.python.org/pipermail/python-dev/2008-June/079988.html Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names in the spirit of 3.0 are available via a #define only. See the email thread.
* Renamed PyString to PyBytesChristian Heimes2008-05-261-9/+9
|
* Re-implement the 'warnings' module in C. This allows for usage of theBrett Cannon2008-04-121-75/+0
| | | | | | | | | 'warnings' code in places where it was previously not possible (e.g., the parser). It could also potentially lead to a speed-up in interpreter start-up if the C version of the code (_warnings) is imported over the use of the Python version in key places. Closes issue #1631171.
* Modified PyImport_Import and PyImport_ImportModule to always use absolute ↵Christian Heimes2008-01-031-1/+1
| | | | | | imports by calling __import__ with an explicit level of 0 Added a new API function PyImport_ImportModuleNoBlock. It solves the problem with dead locks when mixing threads and imports
* Fix a crasher where Python code managed to infinitely recurse in C code withoutBrett Cannon2007-09-071-0/+8
| | | | | | | ever going back out to Python code in PyObject_Call(). Required introducing a static RuntimeError instance so that normalizing an exception there is no reliance on a recursive call that would put the exception system over the recursion check itself.
* SF #1669182, 2.5 was already fixed. Just assert in 2.6 since string exceptionsNeal Norwitz2007-02-261-2/+3
| | | | are gone.
* When printing an unraisable error, don't print exceptions. before the name.Neal Norwitz2007-02-261-1/+2
| | | | This duplicates the behavior whening normally printing exceptions.
* Prevent crash on shutdown which can occur if we are finalizingNeal Norwitz2007-01-051-1/+2
| | | | | | | and the module dict has been cleared already and some object raises a warning (like in a __del__). Will backport.
* Forward-port of r52136,52138: a review of overflow-detecting code.Armin Rigo2006-10-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | * unified the way intobject, longobject and mystrtoul handle values around -sys.maxint-1. * in general, trying to entierely avoid overflows in any computation involving signed ints or longs is extremely involved. Fixed a few simple cases where a compiler might be too clever (but that's all guesswork). * more overflow checks against bad data in marshal.c. * 2.5 specific: fixed a number of places that were still confusing int and Py_ssize_t. Some of them could potentially have caused "real-world" breakage. * list.pop(x): fixing overflow issues on x was messy. I just reverted to PyArg_ParseTuple("n"), which does the right thing. (An obscure test was trying to give a Decimal to list.pop()... doesn't make sense any more IMHO) * trying to write a few tests...
* On Windows, make PyErr_Warn an exported function again.Thomas Heller2006-08-041-1/+1
|
* Add PyErr_WarnEx() so C code can pass the stacklevel to warnings.warn().Neal Norwitz2006-07-301-2/+13
| | | | | | This provides the proper warning for struct.pack(). PyErr_Warn() is now deprecated in favor of PyErr_WarnEx(). As mentioned by Tim Peters on python-dev.
* Fix #1494605.Georg Brandl2006-05-291-1/+2
|
* PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-pasteTim Peters2006-05-281-5/+8
| | | | bug in both: `className` was referenced before being checked for NULL.
* Conversion of exceptions over from faked-up classes to new-style C types.Richard Jones2006-05-271-20/+15
|
* Replace tab inside comment with space.Walter Dörwald2006-05-251-1/+1
|
* PyErr_NewException now accepts a tuple of base classes as itsGeorg Brandl2006-05-231-3/+10
| | | | "base" parameter.
* moduleName can be NULLNeal Norwitz2006-04-171-1/+1
|
* Add missing DECREF to PyErr_WriteUnraisable(). That function reportsThomas Wouters2006-04-151-0/+1
| | | | | | | | | | | exceptions that can't be raised any further, because (for instance) they occur in __del__ methods. The coroutine tests in test_generators was triggering this leak. Remove the leakers' testcase, and add a simpler testcase that explicitly tests this leak to test_generators. test_generators now no longer leaks at all, on my machine. This fix may also solve other leaks, but my full refleakhunting run is still busy, so who knows?
* spread the extern "C" { } magic pixie dust around. Python itself builds nowAnthony Baxter2006-04-131-0/+10
| | | | | using a C++ compiler. Still lots and lots of errors in the modules built by setup.py, and a bunch of warnings from g++ in the core.
* PEP 352 implementation. Creates a new base class, BaseException, which has anBrett Cannon2006-03-011-23/+43
| | | | | | | | | added message attribute compared to the previous version of Exception. It is also a new-style class, making all exceptions now new-style. KeyboardInterrupt and SystemExit inherit from BaseException directly. String exceptions now raise DeprecationWarning. Applies patch 1104669, and closes bugs 1012952 and 518846.
* Updates to the with-statement:Guido van Rossum2006-02-281-0/+1
| | | | | | | | | | | | | | | | - New semantics for __exit__() -- it must re-raise the exception if type is not None; the with-statement itself doesn't do this. (See the updated PEP for motivation.) - Added context managers to: - file - thread.LockType - threading.{Lock,RLock,Condition,Semaphore,BoundedSemaphore} - decimal.Context - Added contextlib.py, which defines @contextmanager, nested(), closing(). - Unit tests all around; bot no docs yet.
* PyErr_ProgramText(): Grrrrrr.Tim Peters2006-02-271-1/+1
| | | | | | | | | | | In a Windows debug build, trying to open a file using an empty string as the name causes assertion death inside MS's C runtime code. We probably need to worm around that in many places. I'm worming around it here to stop the new test_with.py from assert-dying in the Windows debug build (it calls compile() with an empty string for "the file name", which indirectly leads to C-level code in Python trying to fopen("", "r")).
* Use Py_ssize_t to count theMartin v. Löwis2006-02-161-1/+1
|
* -X died some time ago; remove a tiny bit of associated cruft.Michael W. Hudson2005-01-181-4/+0
|
* Changed random calls to PyThreadState_Get() to use the macroNicholas Bastin2004-03-241-1/+1
|
* Getting rid of all the code inside #ifdef macintosh too.Jack Jansen2003-11-201-6/+0
|
* Made function declaration a proper C prototypeArmin Rigo2003-10-251-1/+1
|
* Simplify and speedup uses of Py_BuildValue():Raymond Hettinger2003-10-121-3/+3
| | | | | | * Py_BuildValue("(OOO)",a,b,c) --> PyTuple_Pack(3,a,b,c) * Py_BuildValue("()",a) --> PyTuple_New(0) * Py_BuildValue("O", a) --> Py_INCREF(a)
* Fix [ 771097 ] frozen programs fail due to implicit import of "warnings".Mark Hammond2003-07-151-3/+4
| | | | | | If the initial import of warnings fails, clear the error. When the module is actually needed, if the original import failed, see if it has managed to find its way to sys.modules yet and if so, remember it.
* PyErr_NormalizeException(): in the type==NULL test, we should simplyGuido van Rossum2003-04-101-3/+2
| | | | | | | | return. Setting an exception can mess with the exception state, and continuing is definitely wrong (since type is dereferenced later on). Some code that calls this seems to be prepared for a NULL exception type, so let's be safe rather than sorry and simply assume there's nothing to normalize in this case.
* Fix bug 683658 - PyErr_Warn may cause import deadlock.Mark Hammond2003-02-191-5/+4
|
* Constify filenames and scripts. Fixes #651362.Martin v. Löwis2002-12-111-5/+5
|
* Fix [ 616716 ] Bug in PyErr_SetExcFromWindowsMark Hammond2002-10-041-9/+28
| | | | | | Ensure that even if FormatMessage fails we (a) don't crash, and (b) provide something useful. Bugfix candidate.
* Fix errors to pep277 checkin identified by Neal Norwitz.Mark Hammond2002-10-041-3/+3
|
* Patch 594001: PEP 277 - Unicode file name support for Windows NT.Mark Hammond2002-10-031-10/+82
|
* New functions for extension writers on Windows:Thomas Heller2002-07-291-3/+17
| | | | | | | | | | PyErr_SetExcFromWindowsErr(), PyErr_SetExcFromWindowsErrWithFilename(). Similar to PyErr_SetFromWindowsErrWithFilename() and PyErr_SetFromWindowsErr(), but they allow to specify the exception type to raise. Available on Windows. See SF patch #576458.
* Patch #569753: Remove support for WIN16.Martin v. Löwis2002-06-301-4/+4
| | | | Rename all occurrences of MS_WIN32 to MS_WINDOWS.
* Mass checkin of universal newline support.Jack Jansen2002-04-141-2/+2
| | | | | | | | Highlights: import and friends will understand any of \r, \n and \r\n as end of line. Python file input will do the same if you use mode 'U'. Everything can be disabled by configuring with --without-universal-newlines. See PEP278 for details.
* Patch #494045: patches errno and stat to cope on plan9.Martin v. Löwis2002-03-091-1/+9
|
* Patch #50002: Display line information for bad \x escapes:Martin v. Löwis2002-03-031-1/+23
| | | | | | - recognize "SyntaxError"s by the print_file_and_line attribute. - add the syntaxerror attributes to all exceptions in compile.c. Fixes #221791
* SF bug [#467265] Compile errors on SuSe Linux on IBM/s390.Tim Peters2001-10-021-1/+1
| | | | | | | Unknown whether this fixes it. - stringobject.c, PyString_FromFormatV: don't assume that va_list is of a type that can be copied via an initializer. - errors.c, PyErr_Format: add a va_end() to balance the va_start().
* PyErr_NormalizeException()Jeremy Hylton2001-09-261-1/+12
| | | | | | | | | | | | | | | | | | If a new exception occurs while an exception instance is being created, try harder to make sure there is a traceback. If the original exception had a traceback associated with it and the new exception does not, keep the old exception. Of course, callers to PyErr_NormalizeException() must still be prepared to have tb set to NULL. XXX This isn't an ideal solution, but it's better than no traceback at all. It occurs if, for example, the exception occurs when the call to the constructor fails before any Python code is executed. Guido suggests that it there is Python code that was about to be executed -- but wasn't, say, because it was called with the wrong number of arguments -- then we should point at the first line of the code object anyway.
* PyErr_Format(): Factor out most of this code intoBarry Warsaw2001-08-241-114/+1
| | | | | PyString_FromFormat() since it's much more generally useful than just for exceptions.
* PyErr_Occurred(): Use PyThreadState_GET(), which saves a tiny function callTim Peters2001-05-301-1/+1
| | | | | | | | in release builds. Suggested by Martin v. Loewis. I'm half tempted to macroize PyErr_Occurred too, as the whole thing could collapse to just _PyThreadState_Current->curexc_type
* Use Py_CHARMASK for ctype macros. Fixes bug #232787.Martin v. Löwis2001-03-061-4/+4
|
* Add PyErr_WarnExplicit(), which calls warnings.warn_explicit(), withGuido van Rossum2001-02-281-0/+42
| | | | explicit filename, lineno etc. arguments.
* Improve SyntaxErrors for bad future statements. Set file and locationJeremy Hylton2001-02-281-0/+79
| | | | | | | for errors raised in future.c. Move some helper functions from compile.c to errors.c and make them API functions: PyErr_SyntaxLocation() and PyErr_ProgramText().