summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* Moved mac-specific speedup to a different place (Jack)Guido van Rossum1997-10-081-5/+5
|
* Fixed for WITHOUT_COMPLEX compilation (Jack)Guido van Rossum1997-10-081-1/+2
|
* New version of PyErr_NewException() that is compatible with -X option.Guido van Rossum1997-10-031-14/+35
|
* Initialize Py_UseClassExceptionsFlag to 1.Guido van Rossum1997-10-031-1/+1
|
* Remove unreachable "return 1" at end of ensure_fromlist().Guido van Rossum1997-10-031-1/+1
|
* Fix small omission: with all the new code, sys.exit(None) would printGuido van Rossum1997-10-031-0/+2
| | | | "None"; this should be equivalent to sys.exit(0).
* Change PyEval_SaveThread() and PyEval_RestoreThread() to always do theGuido van Rossum1997-09-301-12/+9
| | | | | | tstate swapping. Only the acquiring and releasing of the lock is conditional (twice, under ``#ifdef WITH_THREAD'' and inside ``if (interpreter_lock)'').
* Fix a bug in this code that made it do the wrong thing when an optionGuido van Rossum1997-09-301-1/+4
| | | | was a single '-'. Thanks to Andrew Kuchling.
* PyErr_NormalizeException(): If the exception's type is a class and theBarry Warsaw1997-09-301-0/+8
| | | | | instance's class is a subclass of this, then use the instance's class as the exception type.
* Get DLL version from a variable.Guido van Rossum1997-09-291-1/+3
|
* Release interpreter lock around readline call in [raw_]input().Guido van Rossum1997-09-261-0/+2
|
* Py_Initialize(): move the call to _PyImport_FixupExtension() to afterBarry Warsaw1997-09-181-1/+1
| | | | | the phase 2 init of the __builtin__ module, so that multiple interpreters will get the right exceptions.
* initerrors(): Eliminate circular reference which was causing a smallBarry Warsaw1997-09-181-3/+3
| | | | | | | | | | | | but annoying memory leak. This was introduced when PyExc_Exception was added; the loop above populating the PyExc_StandardError exception tuple started at index 1 in bltin_exc, but PyExc_Exception was added at index 0, so PyExc_StandardError was getting inserted in itself! How else can a tuple include itself?! Change the loop to start at index 2. This was a *fun* one! :-)
* [Py_Exc]NumberError => [Py_Exc]ArithmeticErrorBarry Warsaw1997-09-161-7/+7
|
* PyErr_Print(): When printing a class exception, try to dig out theBarry Warsaw1997-09-161-6/+21
| | | | | __module__ string and if found, print <module>.<class>, unless <module> == "exceptions".
* New API PyErr_NewException(name, base, dict) to create simple new exceptions.Guido van Rossum1997-09-161-0/+31
|
* Introduce PyExc_Exception as the conceptual root class for all exceptions.Guido van Rossum1997-09-161-0/+7
|
* Added docstrings. Not for the obsolete functions though.Guido van Rossum1997-09-091-6/+46
|
* Deleted find_module_in_package and find_module_in_directory -- theyGuido van Rossum1997-09-091-53/+0
| | | | aren't needed and it was a mistake to add them.
* Crrected a flow control error that caused the wrong error message whenGuido van Rossum1997-09-091-22/+6
| | | | | | load-module() didn't find a built-in or frozen module. Also got rid of is_frozen(), which duplicated the functionality of find_frozen()!=NULL.
* Added support for __all__, which should be a list of modules to beGuido van Rossum1997-09-081-3/+16
| | | | imported when the user says "from package import *".
* Bugfix: import A.B from inside package was busted by mark_miss optimization.Guido van Rossum1997-09-071-1/+1
|
* Significant speedup -- when a submodule imports a global module, add aGuido van Rossum1997-09-061-5/+20
| | | | | | | | | | | | | | | | | | dummy entry to sys.modules, marking the absence of a submodule by the same name. Thus, if module foo.bar executes the statement "import time", sys.modules['foo.time'] will be set to None, once the absence of a module foo.time is confirmed (by looking for it in foo's path). The next time when foo.bar (or any other submodule of foo) executes "import time", no I/O is necessary to determine that there is no module foo.time. (Justification: It may seem strange to pollute sys.modules. However, since we're doing the lookup anyway it's definitely the fastest solution. This is the same convention that 'ni' uses and I haven't heard any complaints.)
* Fix reload() for package submodules.Guido van Rossum1997-09-061-2/+24
|
* Phase two of package import. "import a.b.c" and all variants now do theGuido van Rossum1997-09-061-17/+299
| | | | | | | | | | | | | | | right thing. Still to do: - Make reload() of a submodule work. - Performance tweaks -- currently, a submodule that tries to import a global module *always* searches the package directory first, even if the global module was already imported. Not sure how to solve this one; probably need to record misses per package. - Documentation!
* Fixed some details of printing the str() of an exception. This fixesGuido van Rossum1997-09-051-2/+6
| | | | | a core dump when __str__() returns a non-string, and plugs a memory leak as well: the result of PyObject_Str() was never DECREFed.
* First part of package support.Guido van Rossum1997-09-055-148/+460
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This doesn't yet support "import a.b.c" or "from a.b.c import x", but it does recognize directories. When importing a directory, it initializes __path__ to a list containing the directory name, and loads the __init__ module if found. The (internal) find_module() and load_module() functions are restructured so that they both also handle built-in and frozen modules and Mac resources (and directories of course). The imp module's find_module() and (new) load_module() also have this functionality. Moreover, imp unconditionally defines constants for all module types, and has two more new functions: find_module_in_package() and find_module_in_directory(). There's also a new API function, PyImport_ImportModuleEx(), which takes all four __import__ arguments (name, globals, locals, fromlist). The last three may be NULL. This is currently the same as PyImport_ImportModule() but in the future it will be able to do relative dotted-path imports. Other changes: - bltinmodule.c: in __import__, call PyImport_ImportModuleEx(). - ceval.c: always pass the fromlist to __import__, even if it is a C function, so PyImport_ImportModuleEx() is useful. - getmtime.c: the function has a second argument, the FILE*, on which it applies fstat(). According to Sjoerd this is much faster. The first (pathname) argument is ignored, but remains for backward compatibility (so the Mac version still works without changes). By cleverly combining the new imp functionality, the full support for dotted names in Python (mini.py, not checked in) is now about 7K, lavishly commented (vs. 14K for ni plus 11K for ihooks, also lavishly commented). Good night!
* 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
|