summaryrefslogtreecommitdiffstats
path: root/Python/exceptions.c
Commit message (Collapse)AuthorAgeFilesLines
* Conversion of exceptions over from faked-up classes to new-style C types.Richard Jones2006-05-271-2032/+0
|
* Remove bogus DECREF of self.Martin v. Löwis2006-05-151-65/+32
| | | | | Change __str__() functions to METH_O. Change WindowsError__str__ to use PyTuple_Pack.
* Change WindowsError to carry the Win32 error code in winerror,Martin v. Löwis2006-05-111-4/+121
| | | | | and the DOS error code in errno. Revert changes where WindowsError catch blocks unnecessarily special-case OSError.
* - Add new Warning class, ImportWarningThomas Wouters2006-04-271-0/+5
| | | | | | | | | | | | | | - Warn-raise ImportWarning when importing would have picked up a directory as package, if only it'd had an __init__.py. This swaps two tests (for case-ness and __init__-ness), but case-test is not really more expensive, and it's not in a speed-critical section. - Test for the new warning by importing a common non-package directory on sys.path: site-packages - In regrtest.py, silence warnings generated by the build-environment because Modules/ (which is added to sys.path for Setup-created modules) has 'zlib' and '_ctypes' directories without __init__.py's.
* Make Py_BuildValue, PyObject_CallFunction andMartin v. Löwis2006-04-141-3/+4
| | | | PyObject_CallMethod aware of PY_SSIZE_T_CLEAN.
* low-hanging fruit in Python/ - g++ still hates all the enum_kind declarationsAnthony Baxter2006-04-111-1/+1
| | | | in Python/Python-ast.c. Not sure what to do about those.
* Change int to Py_ssize_t in several places.Martin v. Löwis2006-03-071-2/+2
| | | | | Add (int) casts to silence compiler warnings. Raise Python exceptions for overflows.
* Remove commented codeNeal Norwitz2006-03-031-24/+1
|
* Add a missing Py_DECREF to BaseException__unicode__ .Brett Cannon2006-03-021-2/+8
|
* Document PEP 352 changes. Also added GeneratorExit.Brett Cannon2006-03-011-7/+2
|
* PEP 352 implementation. Creates a new base class, BaseException, which has anBrett Cannon2006-03-011-153/+245
| | | | | | | | | 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.
* Use PyString_FromFormat for formatting error messages.Martin v. Löwis2006-02-161-42/+36
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-52/+66
|
* PEP 342 implementation. Per Guido's comments, the generator throw()Phillip J. Eby2005-08-021-0/+5
| | | | | method still needs to support string exceptions, and allow None for the third argument. Documentation updates are needed, too.
* Stop producing or using OverflowWarning. PEP 237 thought this wouldTim Peters2004-08-251-1/+3
| | | | | | | happen in 2.3, but nobody noticed it still was getting generated (the warning was disabled by default). OverflowWarning and PyExc_OverflowWarning should be removed for 2.5, and left notes all over saying so.
* Simplify and speedup uses of Py_BuildValue():Raymond Hettinger2003-10-121-1/+1
| | | | | | * 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 refcount leak in the UnicodeError constructor:Walter Dörwald2003-08-141-1/+1
| | | | | When parsing the constructor arguments failed, a reference to the argument tuple was leaked.
* Add a unicode prefix to the characters in the UnicodeEncodeError andWalter Dörwald2003-08-121-6/+6
| | | | UnicodeTranslateError message.
* Enhance message for UnicodeEncodeError and UnicodeTranslateError.Walter Dörwald2003-08-121-5/+21
| | | | | If there is only one bad character it will now be printed in a form that is a valid Python string.
* Remove unused variables.Walter Dörwald2003-02-241-9/+0
|
* Provide __module__ attributes for functions defined in C and Python.Jeremy Hylton2003-01-311-6/+14
| | | | | | | | | | | | | | __module__ is the string name of the module the function was defined in, just like __module__ of classes. In some cases, particularly for C functions, the __module__ may be None. Change PyCFunction_New() from a function to a macro, but keep an unused copy of the function around so that we don't change the binary API. Change pickle's save_global() to use whichmodule() if __module__ is None, but add the __module__ logic to whichmodule() since it might be used outside of pickle.
* Patch #614055: Support OpenVMS.Martin v. Löwis2002-12-061-0/+13
|
* Fix PEP 293 related problems with --disable-unicode buildsWalter Dörwald2002-11-211-0/+6
| | | | | reported by Michael Hudson in http://mail.python.org/pipermail/python-dev/2002-November/030299.html
* Two more cases of switch(PySequence_Size()) without checking for case -1.Neal Norwitz2002-09-181-0/+7
| | | | | | | (Same problem as last checkin for SF bug 610610) Need to clear the error and proceed. Backport candidate
* Fix SF bug 610610 (reported by Martijn Pieters, diagnosed by Neal Norwitz).Guido van Rossum2002-09-181-0/+3
| | | | | | | | The switch in Exception__str__ didn't clear the error if PySequence_Size() raised an exception. Added a case -1 which clears the error and falls through to the default case. Definite backport candidate (this dates all the way to Python 2.0).
* Add a custom __str__ method to KeyError that applies repr() to theGuido van Rossum2002-09-031-2/+40
| | | | | missing key. (Also added a guard to SyntaxError__str__ to prevent calling PyString_Check(NULL).)
* Removed bogus PyUnicodeTranslateError_GetEncoding, asWalter Dörwald2002-09-021-5/+0
| | | | | UnicodeTranslateError doesn't have an encoding attribute. (Spotted by Neal Norwitz)
* Limit the length of attribute names in exception messagesWalter Dörwald2002-09-021-3/+3
| | | | to prevent buffer overflows (spotted by Neal Norwitz).
* PEP 293 implemention (from SF patch http://www.python.org/sf/432401)Walter Dörwald2002-09-021-0/+603
|
* Added a FutureWarning for constructs that will change semantically inBarry Warsaw2002-08-141-1/+9
| | | | | the future. Changed PEP 237 hex constant warnings from DeprecationWarning to FutureWarning. Updated the documentation.
* Excise DL_IMPORT/EXPORT from object.h, and related files. This patchMark Hammond2002-07-291-2/+2
| | | | | also adds 'extern' to PyAPI_DATA rather than at each declaration, as discussed with Tim and Guido.
* Patch #568124: Add doc string macros.Martin v. Löwis2002-06-131-91/+58
|
* As discussed on python-dev, add a mechanism to indicate featuresNeal Norwitz2002-05-291-0/+9
| | | | | that are in the process of deprecation (PendingDeprecationWarning). Docs could be improved.
* add comment reminding people about class hierarchy in Doc/lib/libexcs.texSkip Montanaro2002-03-281-0/+5
|
* Patch #50002: Display line information for bad \x escapes:Martin v. Löwis2002-03-031-1/+2
| | | | | | - recognize "SyntaxError"s by the print_file_and_line attribute. - add the syntaxerror attributes to all exceptions in compile.c. Fixes #221791
* Use PyOS_snprintf instead of sprintf.Jeremy Hylton2001-11-281-11/+11
| | | | | Just being sure. The old code looks like it was safe, but there's no harm in double-checking.
* weakref.ReferenceError becomes a built-in exception now that weak ref objectsFred Drake2001-10-051-0/+6
| | | | | are moving into the core; with these changes, it will be possible for the exception to be raised without the weakref module ever being imported.
* Introduce OverflowWarning -- to be issued when short int operationsGuido van Rossum2001-08-231-0/+7
| | | | are overflowing and a long int operation is substituted.
* Merge of descr-branch back into trunk.Tim Peters2001-08-021-12/+25
|
* Iterators phase 1. This comprises:Guido van Rossum2001-04-201-0/+7
| | | | | | | | | | | | | | | | | | | | | | new slot tp_iter in type object, plus new flag Py_TPFLAGS_HAVE_ITER new C API PyObject_GetIter(), calls tp_iter new builtin iter(), with two forms: iter(obj), and iter(function, sentinel) new internal object types iterobject and calliterobject new exception StopIteration new opcodes for "for" loops, GET_ITER and FOR_ITER (also supported by dis.py) new magic number for .pyc files new special method for instances: __iter__() returns an iterator iteration over dictionaries: "for x in dict" iterates over the keys iteration over files: "for x in file" iterates over lines TODO: documentation test suite decide whether to use a different way to spell iter(function, sentinal) decide whether "for key in dict" is a good idea use iterators in map/filter/reduce, min/max, and elsewhere (in/not in?) speed tuning (make next() a slot tp_next???)
* Make some private symbols static.Guido van Rossum2001-04-141-2/+2
|
* SyntaxError__init__(): Be a little more robust when picking apart theFred Drake2001-02-281-16/+22
| | | | | location information for the SyntaxError -- do not do more than we need to, stopping as soon as an exception has been raised.
* SF patch 404928: Support for next Cygwin gcc (2.95.2-8)Tim Peters2001-02-281-8/+2
|
* Leak pluggin', bug fixin' and better documentin'. Specifically,Barry Warsaw2001-01-231-56/+72
| | | | | | | | | | | | | module__doc__: Document the Warning subclass heirarchy. make_class(): Added a "goto finally" so that if populate_methods() fails, the return status will be -1 (failure) instead of 0 (success). fini_exceptions(): When decref'ing the static pointers to the exception classes, clear out their dictionaries too. This breaks a cycle from class->dict->method->class and allows the classes with unbound methods to be reclaimed. This plugs a large memory leak in a common Py_Initialize()/dosomething/Py_Finalize() loop.
* Add definitions for standard warning category classes (PyExc_WarningGuido van Rossum2000-12-151-0/+36
| | | | etc.).
* Ka-Ping Yee <ping@lfw.org>:Fred Drake2000-10-241-1/+1
| | | | | | Changes to error messages to increase consistency & clarity. This (mostly) closes SourceForge patch #101839.
* Remove a couple of warnings turned up by "gcc -Wall".Fred Drake2000-08-181-2/+2
|
* SyntaxError__classinit__(): Slight reorg for simplicity.Barry Warsaw2000-08-181-4/+4
|
* SyntaxError__str__(): Fix two memory problems discovered by Insure.Barry Warsaw2000-08-161-4/+9
| | | | | | | First, the allocated buffer was never freed after using it to create the PyString object. Second, it was possible that have_filename would be false (meaning that filename was not a PyString object), but that the code would still try to PyString_GET_SIZE() it.
* my_basename(): Removes the leading path components from a path name,Fred Drake2000-08-151-2/+23
| | | | | | | | returning a pointer to the start of the file's "base" name; similar to os.path.basename(). SyntaxError__str__(): Use my_basename() to keep the length of the file name included in the exception message short.