summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* Inline PyObject_CallObject (Marc-Andre Lemburg).Guido van Rossum1997-08-301-0/+5
|
* Two independent changes (oops):Guido van Rossum1997-08-291-4/+35
| | | | | | | | | - Changed semantics for initialized flag (again); forget the ref counting, forget the fatal errors -- redundant calls to Py_Initialize() or Py_Finalize() calls are simply ignored. - Automatically import site.py on initialization, unless a flag is set not to do this by main().
* Removed obsolete exception PyExc_AccessError.Barry Warsaw1997-08-291-43/+171
| | | | | | | | | | | | | | | | | | | | | Added PyErr_MemoryErrorInst to hold the pre-instantiated instance when using class based exceptions. Simplified the creation of all built-in exceptions, both class based and string based. Actually, for class based exceptions, the string ones are still created just in case there's a problem creating the class based ones (so you still get *some* exception handling!). Now the init and fini functions run through a list of structure elements, creating the strings (and optionally classes) for every entry. initerrors(): the new base class exceptions StandardError, LookupError, and NumberError are initialized when using string exceptions, to tuples containing the list of derived string exceptions. This GvR trick enables forward compatibility! One bit of nastiness is that the C code has to know the inheritance tree embodied in exceptions.py. Added the two phase init and fini functions.
* Added Py_UseClassExceptionsFlag, the variable containing the state ofBarry Warsaw1997-08-291-5/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the -X command line option. Py_Initialize(): Handle the two phase initialization of the built-in module. Py_Finalize(): Handle the two phase finalization of the built-in module. parse_syntax_error(): New function which parses syntax errors that PyErr_Print() will catch. This correctly parses such errors regardless of whether PyExc_SyntaxError is an old-style string exception or new-fangled class exception. PyErr_Print(): Many changes: 1. Normalize the exception. 2. Handle SystemExit exceptions which might be class based. Digs the exit code out of the "code" attribute. String based SystemExit is handled the same as before. 3. Handle SyntaxError exceptions which might be class based. Digs the various information bits out of the instance's attributes (see parse_syntax_error() for details). String based SyntaxError still works too. 4. Don't write the `:' after the exception if the exception is class based and has an empty string str() value.
* PyErr_NoMemory(): If the pre-instantiated memory exception is non-nullBarry Warsaw1997-08-291-1/+9
| | | | | | (PyExc_MemoryErrorInst) raise this instead of PyExc_MemoryError. This only happens when exception classes are enabled (e.g. when Python is started with -X).
* Cprrect stuoid tyops -- was comparing variabes with themselves becauseGuido van Rossum1997-08-291-3/+3
| | | | of co/cp mixup.
* eval_code2(), set_exc_info(): Call PyErr_NormalizeException() theBarry Warsaw1997-08-281-2/+2
| | | | | | former rather than the latter, since PyErr_NormalizeException takes PyObject** and I didn't want to change the interface for set_exc_info (but I did want the changes propagated to eval_code2!).
* PyErr_Print(): Use PyErr_GivenExceptionMatches() instead of pointerBarry Warsaw1997-08-261-2/+4
| | | | compares to test for SystemExit and SyntaxError.
* unpack_sequence(): In finally clause, watch out for Py_DECREFBarry Warsaw1997-08-251-2/+2
| | | | evaluating its arguments twice.
* eval_code2(): collapsed the implementations of UNPACK_TUPLE andBarry Warsaw1997-08-251-33/+74
| | | | | | | | | | | | | | UNPACK_LIST byte codes and added a third code path that allows generalized sequence unpacking. Now both syntaxes: a, b, c = seq [a, b, c] = seq can be used to unpack any sequence with the exact right number of items. unpack_sequence(): out-lined implementation of generalized sequence unpacking. tuple and list unpacking are still inlined.
* cmp_exception gets promoted (essentially) to the C API functionBarry Warsaw1997-08-221-59/+10
| | | | | | | | | | | PyErr_GivenExceptionMatches(). set_exc_info(): make sure to normalize exceptions. do_raise(): Use PyErr_NormalizeException() if type is a class. loop_subscript(): Use PyErr_ExceptionMatches() instead of raw pointer compare for PyExc_IndexError.
* Three new C API functions:Barry Warsaw1997-08-221-0/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | - int PyErr_GivenExceptionMatches(obj1, obj2) Returns 1 if obj1 and obj2 are the same object, or if obj1 is an instance of type obj2, or of a class derived from obj2 - int PyErr_ExceptionMatches(obj) Higher level wrapper around PyErr_GivenExceptionMatches() which uses PyErr_Occurred() as obj1. This will be the more commonly called function. - void PyErr_NormalizeException(typeptr, valptr, tbptr) Normalizes exceptions, and places the normalized values in the arguments. If type is not a class, this does nothing. If type is a class, then it makes sure that value is an instance of the class by: 1. if instance is of the type, or a class derived from type, it does nothing. 2. otherwise it instantiates the class, using the value as an argument. If value is None, it uses an empty arg tuple, and if the value is a tuple, it uses just that.
* Two new built-in functions: issubclass() and isinstance(). Both takeBarry Warsaw1997-08-221-5/+59
| | | | | | | | | | | | classes as their second arguments. The former takes a class as the first argument and returns true iff first is second, or is a subclass of second. The latter takes any object as the first argument and returns true iff first is an instance of the second, or any subclass of second. Also, change all occurances of pointer compares against PyExc_IndexError with PyErr_ExceptionMatches() calls.
* Reverse the search order for the Don Beaudry hook so that the firstGuido van Rossum1997-08-221-4/+3
| | | | class wins. Makes more sense.
* Added new Py_IsInitalized() API function to test the 'initialized' flag.Guido van Rossum1997-08-221-0/+8
|
* Added missing newline to warning msgGuido van Rossum1997-08-211-1/+1
|
* Use a counter instead of a Boolean to check for initialized; n callsGuido van Rossum1997-08-201-5/+5
| | | | to Py_Initialize will be undone by n calls to Py_Uninitialize.
* set sharedlib extensions properly for NeXT (Ted Horst)Guido van Rossum1997-08-161-0/+2
|
* Keep gcc -Wall happyGuido van Rossum1997-08-152-3/+2
|
* Use _beginthread() and _endthread() in favor of CreateThread() andGuido van Rossum1997-08-141-16/+8
| | | | | | | ExitThread(). As discussed in c.l.p, this takes care of initialization and finalization of thread-local storage allocated by the C runtime system. Not sure whether non-MS compilers grok this though (but who cares :-).
* Added Jim Fulton's PyImport_Import(), which calls whateverGuido van Rossum1997-08-141-0/+78
| | | | __import__() hook is currently installed.
* Use string interning and caching to get speedups on the mac (Jack).Guido van Rossum1997-08-121-1/+17
|
* Use strerror on the mac if using MSL (Jack).Guido van Rossum1997-08-121-6/+0
|
* Remove unised variableGuido van Rossum1997-08-071-1/+0
|
* Merge Py_Cleanup() into Py_Finalize(). Call the various small Fini()Guido van Rossum1997-08-051-36/+43
| | | | functions.
* New rules for deleting modules. Rather than having an elaborateGuido van Rossum1997-08-051-1/+29
| | | | | | | | | | | | scheme based on object's types, have a simple two-phase scheme based on object's *names*: /* To make the execution order of destructors for global objects a bit more predictable, we first zap all objects whose name starts with a single underscore, before we clear the entire dictionary. We zap them by replacing them with None, rather than deleting them from the dictionary, to avoid rehashing the dictionary (to some extent). */
* Renamed a local label that was accidentally grandly renamed toGuido van Rossum1997-08-051-3/+3
| | | | 'Py_Cleanup' back to 'cleanup'.
* The last of the mass checkins for separate (sub)interpreters.Guido van Rossum1997-08-027-218/+542
| | | | | | | Everything should now work again. See the comments for the .h files mass checkin (e.g. pystate.h) for more detail.
* Removed fatal errors from Py_Initmodule4() (and thus fromGuido van Rossum1997-08-021-12/+12
| | | | | | | | | | | | Py_Initmodule(), which is a macro wrapper around it). The return value is now a NULL pointer if the initialization failed. This may make old modules fail with a SEGFAULT, since they don't expect this kind of failure. That's OK, since (a) it "never" happens, and (b) they would fail with a fatal error otherwise, anyway. Tons of extension modules should now check the return value of Py_Initmodule*() -- that's on my TODO list.
* Extend the "Don Beaudry hack" with "Guido's corollary" -- if the baseGuido van Rossum1997-07-311-10/+27
| | | | | class has a __class__ attribute, call that to create the new class. This allows us to write metaclasses purely in C!
* Plugged a leak. (The same as the one plugged in compile.c -- forgotGuido van Rossum1997-07-261-0/+1
| | | | to free lnotab).
* Plug a leak in code_dealloc() (and reordered the deallocs to match theGuido van Rossum1997-07-251-3/+2
| | | | | | order of the variables in the declarations). Also removed an entry in the TODO list that's done.
* Removed some variables that are used to exchange data between import.c andGuido van Rossum1997-07-213-14/+6
| | | | | | | | importdl.c: the MAXSUFFIXSIZE macro is now defined in importdl.h, and the modules dictionary is now passed using PyImport_GetModuleDict(). Also undefine USE_SHLIB for AIX -- in AIX 4.2 and up, dlfcn.h exists but we don't want to use it.
* frozenmain.c is now also in the library,Guido van Rossum1997-07-192-6/+2
| | | | with entry point Py_FrozenMain().
* Oops -- this contains frozen bytecode, but it was Python 1.4 bytecode!Guido van Rossum1997-07-191-7/+7
|
* Moved PyEval_{Acquire,Release}Thread() to within the same #ifdefGuido van Rossum1997-07-191-21/+23
| | | | | | WITH_THREAD as PyEval_InitThreads(). Removed use of Py_SuppressPrintingFlag.
* Removed a bunch of extern declarations of functions that are nowGuido van Rossum1997-07-191-7/+0
| | | | properly declared in Python.h.
* Make it return a _const_ char*.Guido van Rossum1997-07-193-5/+2
|
* New build procedure.Guido van Rossum1997-07-191-9/+9
|
* Tracking changes to Py_Main():Guido van Rossum1997-07-191-18/+4
| | | | | | | | - Got rid of inspection of some environment variables. - Got rid of Py_GetProgramName() and related logic. - Print the version header *after* successful initialization.
* Moved some stuff here from main.c (part of a big restructuring - waitGuido van Rossum1997-07-191-1/+26
| | | | | | | | | | | | | for more!). - The global flags that can be set from environment variables are now set in Py_Initialize (except the silly Py_SuppressPrint, which no longer exists). This saves duplicate code in frozenmain.c and main.c. - Py_GetProgramName() is now here; added Py_SetProgramName(). An embedding program should no longer provide Py_GetProgramName(), instead it should call Py_SetProgramName() *before* calling Py_Initialize().
* Remove confusing usage comments at end.Guido van Rossum1997-07-191-28/+0
|
* PyEval_SaveThread() and PyEval_RestoreThread() now return/take aGuido van Rossum1997-07-181-6/+28
| | | | | | | | | | | | | | | | PyThreadState pointer instead of a (frame) PyObject pointer. This makes much more sense. It is backward incompatible, but that's no problem, because (a) the heaviest users are the Py_{BEGIN,END}_ ALLOW_THREADS macros here, which have been fixed too; (b) there are very few direct users; (c) those who use it are there will probably appreciate the change. Also, added new functions PyEval_AcquireThread() and PyEval_ReleaseThread() which allows the threads created by the thread module as well threads created by others (!) to set/reset the current thread, and at the same time acquire/release the interpreter lock. Much saner.
* Huge speedup by inlining some common integer operations:Guido van Rossum1997-07-171-5/+75
| | | | | | | int+int, int-int, int <compareop> int, and list[int]. (Unfortunately, int*int is way too much code to inline.) Also corrected a NULL that should have been a zero.
* Fix problem discovered by Greg McFarlane: when an imported moduleGuido van Rossum1997-07-101-0/+7
| | | | | | | | | replaces its own entry in sys.module, reference count errors ensue; even if there is no reference count problem, it would be preferable for the import to yield the new thing in sys.modules anyway (if only because that's what later imports will yield). This opens the road to an official hack to implement a __getattr__ like feature for modules: stick an instance in sys.modules[__name__].
* Fix bug reported by Just: anonymous arguments used for tuples shouldGuido van Rossum1997-07-101-1/+3
| | | | | | have a unique name, otherwise they get squished by locals2fast (or fast2locals, I dunno) when the debugger is invoked before they have been transferred to real locals.
* Add default case (standard conformance) to avoid piling upGuido van Rossum1997-06-021-4/+4
| | | | system specific #ifdefs.
* Can't return 0 from void function...Guido van Rossum1997-05-231-1/+1
|
* PyObject_Compare can raise an exception now.Guido van Rossum1997-05-233-5/+23
|
* PyFile_WriteString now returns an error indicator instead of callingGuido van Rossum1997-05-222-16/+32
| | | | PyErr_Clear(). Add checking of those errors.