summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* Fixed SF bug #663074. The codec system was using global staticGustavo Niemeyer2003-03-193-92/+71
| | | | | | | | | variables to store internal data. As a result, any atempts to use the unicode system with multiple active interpreters, or successive interpreter executions, would fail. Now that information is stored into members of the PyInterpreterState structure.
* Eliminate data dependency in predict macro.Raymond Hettinger2003-03-161-2/+8
| | | | | | | | Added two predictions: GET_ITER --> FOR_ITER FOR_ITER --> STORE_FAST or UNPACK_SEQUENCE Improves timings on pybench and timeit.py. Pystone results are neutral.
* Fix comment and whitespace.Raymond Hettinger2003-03-161-3/+4
|
* Introduced macros for a simple opcode prediction protocol.Raymond Hettinger2003-03-161-6/+35
| | | | | | | | | | | | | | | | | | | Applied to common cases: COMPARE_OP is often followed by a JUMP_IF. JUMP_IF is usually followed by POP_TOP. Shows improved timings on PyStone, PyBench, and specific tests using timeit.py: python timeit.py -s "x=1" "if x==1: pass" python timeit.py -s "x=1" "if x==2: pass" python timeit.py -s "x=1" "if x: pass" python timeit.py -s "x=100" "while x!=1: x-=1" Potential future candidates: GET_ITER predicts FOR_ITER FOR_ITER predicts STORE_FAST or UNPACK_SEQUENCE Also, applied missing goto fast_next_opcode to DUP_TOPX.
* SF patch #701907: More use of fast_next_opcodeRaymond Hettinger2003-03-141-11/+11
| | | | | | | | My previous patches should have used fast_next_opcode in a few places instead of continue. Also, applied one PyInt_AS_LONG macro in a place where the type had already been checked.
* Declare all variables at the start of their scope.Fred Drake2003-03-051-1/+1
|
* Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,Martin v. Löwis2003-03-052-0/+48
| | | | | and not as a side effect of setlocale. Expose it as sys.getfilesystemencoding. Adjust test case.
* Use Carbon.File for FSSpec and FSRef conversion, not macfs.Jack Jansen2003-03-021-4/+4
|
* Added implementation notes for [re]set_exc_info().Guido van Rossum2003-03-011-0/+61
|
* - New function sys.exc_clear() clears the current exception. This isGuido van Rossum2003-03-011-4/+37
| | | | | | rarely needed, but can sometimes be useful to release objects referenced by the traceback held in sys.exc_info()[2]. (SF patch #693195.) Thanks to Kevin Jacobs!
* In the process of adding all the extended slice support I attempted toMichael W. Hudson2003-02-271-4/+4
| | | | | | | change _PyEval_SliceIndex to round massively negative longs up to -INT_MAX, instead of 0 but botched it. Get it right. Thx to Armin for the report.
* Micro-optimizations.Raymond Hettinger2003-02-261-4/+18
| | | | | * List/Tuple checkexact is faster for the common case. * Testing for Py_True and Py_False can be inlined for faster looping.
* Addendum to #683658:Just van Rossum2003-02-251-2/+2
| | | | | | import warnings.py _after_ site.py has run. This ensures that site.py is again the first .py to be imported, giving it back full control over sys.path.
* Remove unused variables.Walter Dörwald2003-02-241-9/+0
|
* Fix SF bug #690435, apply fails to check if warning raises exceptionNeal Norwitz2003-02-231-3/+4
| | | | (patch provided by Greg Chapman)
* After the removal of SET_LINENO, PyCode_Addr2Line has always beenMichael W. Hudson2003-02-221-3/+0
| | | | | | called to find tb_lineno -- even if Py_OptimizeFlag is true. So don't call it again when printing the traceback.
* - PyEval_GetFrame() is now declared to return a PyFrameObject *Guido van Rossum2003-02-192-9/+9
| | | | instead of a plain PyObject *. (SF patch #686601 by Ben Laurie.)
* - sys.path[0] (the directory from which the script is loaded) is nowGuido van Rossum2003-02-191-2/+10
| | | | | turned into an absolute pathname, unless it is the empty string. (SF patch #664376, by Skip Montanaro.)
* Fix bug 683658 - PyErr_Warn may cause import deadlock.Mark Hammond2003-02-192-5/+15
|
* Remove PyArg_ParseTuple() for methods which take no args,Neal Norwitz2003-02-171-23/+13
| | | | use METH_NOARGS instead
* Patch for bug reported in patch #686627: import race condition inMarc-André Lemburg2003-02-141-1/+1
| | | | codecs registry startup.
* - Finally fixed the bug in compile() and exec where a string endingGuido van Rossum2003-02-132-7/+5
| | | | | | | | | with an indented code block but no newline would raise SyntaxError. This would have been a four-line change in parsetok.c... Except codeop.py depends on this behavior, so a compilation flag had to be invented that causes the tokenizer to revert to the old behavior; this required extra changes to 2 .h files, 2 .c files, and 2 .py files. (Fixes SF bug #501622.)
* Cleanup from patch #683257:Neal Norwitz2003-02-121-4/+7
| | | | | | | Add missing INCREFs and re-indent returns to be consistent. Add \n\ for lines in docstring Add a pathetic test Add docs
* Provide access to the import lock, fixing SF bug #580952. This isGuido van Rossum2003-02-121-6/+52
| | | | | | | | mostly from SF patch #683257, but I had to change unlock_import() to return an error value to avoid fatal error. Should this be backported? The patch requested this, but it's a new feature.
* SF #660455 : patch by NNorwitz.Guido van Rossum2003-02-121-1/+2
| | | | | | | | | | "Unsigned" (i.e., positive-looking, but really negative) hex/oct constants with a leading minus sign are once again properly negated. The micro-optimization for negated numeric constants did the wrong thing for such hex/oct constants. The patch avoids the optimization for all hex/oct constants. This needs to be backported to Python 2.2!
* Change filtertuple() to use tp_as_sequence->sq_itemWalter Dörwald2003-02-101-1/+6
| | | | | instead of PyTuple_GetItem, so an overwritten __getitem__ in a tuple subclass works. SF bug #665835.
* Squashed compiler wng about signed/unsigned clash in comparison.Tim Peters2003-02-101-1/+1
|
* Change filterstring() and filterunicode(): If theWalter Dörwald2003-02-101-43/+48
| | | | | | | | | | | | object is not a real str or unicode but an instance of a subclass, construct the output via looping over __getitem__. This guarantees that the result is the same for function==None and function==lambda x:x This doesn't happen for tuples, because filtertuple() uses PyTuple_GetItem(). (This was discussed on SF bug #665835).
* My previous checkin caused compile() to no longer accept buffers, as notedJust van Rossum2003-02-101-5/+7
| | | | | my MAL. Fixed. (Btw. eval() still doesn't take buffers, but that was so even before my patch.)
* patch #683515: "Add unicode support to compile(), eval() and exec"Just van Rossum2003-02-103-9/+56
| | | | Incorporated nnorwitz's comment re. Py__USING_UNICODE.
* Small function call optimization and special build option for call stats.Jeremy Hylton2003-02-053-14/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | -DCALL_PROFILE: Count the number of function calls executed. When this symbol is defined, the ceval mainloop and helper functions count the number of function calls made. It keeps detailed statistics about what kind of object was called and whether the call hit any of the special fast paths in the code. Optimization: When we take the fast_function() path, which seems to be taken for most function calls, and there is minimal frame setup to do, avoid call PyEval_EvalCodeEx(). The eval code ex function does a lot of work to handle keywords args and star args, free variables, generators, etc. The inlined version simply allocates the frame and copies the arguments values into the frame. The optimization gets a little help from compile.c which adds a CO_NOFREE flag to code objects that don't have free variables or cell variables. This change allows fast_function() to get into the fast path with fewer tests. I measure a couple of percent speedup in pystone with this change, but there's surely more that can be done.
* If a float is passed where a int is expected, issue a DeprecationWarningNeil Schemenauer2003-02-041-12/+25
| | | | instead of raising a TypeError. Closes #660144 (again).
* Make sure filter() never returns tuple, str or unicodeWalter Dörwald2003-02-041-5/+22
| | | | subclasses. (Discussed in SF patch #665835)
* PyUnicode_Resize() doesn't free its argument in case of a failure,Walter Dörwald2003-02-041-1/+1
| | | | | so we can jump to the error handling code that does. (Spotted by Neal Norwitz)
* filterstring() and filterunicode() in Python/bltinmodule.cWalter Dörwald2003-02-041-8/+70
| | | | | | | | | | | | | blindly assumed that tp_as_sequence->sq_item always returns a str or unicode object. This might fail with str or unicode subclasses. This patch checks whether the object returned from __getitem__ is a str/unicode object and raises a TypeError if not (and the filter function returned true). Furthermore the result for __getitem__ can be more than one character long, so checks for enough memory have to be done.
* SF #661437, apply() should get PendingDeprecationNeal Norwitz2003-02-031-0/+3
|
* Provide __module__ attributes for functions defined in C and Python.Jeremy Hylton2003-01-312-8/+28
| | | | | | | | | | | | | | __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.
* Style consistency, so "grep ^function ..." works as expected.Fred Drake2003-01-301-2/+4
|
* Patch #636005: Filter unicode into unicode.Martin v. Löwis2003-01-251-0/+62
|
* Raise a TypeError if a float is passed when an integer is specified.Neil Schemenauer2003-01-241-6/+24
| | | | | Calling PyInt_AsLong() on a float truncates it which is almost never the desired behavior. This closes SF bug #660144.
* MacPython-OS9 has had an abort() function for quite a while now, so there's ↵Jack Jansen2003-01-241-3/+0
| | | | no reason to stall in an endless loop, just call abort() on a fatal error.
* MacPython-OS9 specific fix: If there are non-string items on sys.path don't ↵Jack Jansen2003-01-241-15/+18
| | | | try to intern them. This has the theoretical problem that resource filenames on sys.path cannot be unicode objects, but in practice that shouldn't matter.
* Patch #671459: Invoke import hooks in Py_NewInterpreter.Martin v. Löwis2003-01-221-0/+1
|
* Don't use Posix semaphores on Solaris 8. Fixes #662787.Martin v. Löwis2003-01-211-1/+1
|
* SF patch #670367: Micro-optimizations for ceval.cRaymond Hettinger2003-01-191-18/+13
| | | | | | | | | | | | | | | | | | | | Make the code slightly shorter, faster, and easier to read. * Eliminate unused DUP_TOPX code for x==1. compile.c always generates DUP_TOP instead. * Since only two cases remain for DUP_TOPX, replace the switch-case with if-elseif. * The in-lined integer compare does a CheckExact on both arguments. Since the second is a little more likely to fail, test it first. * The switch-case for IS/IS_NOT and IN/NOT_IN can separate the regular and inverted cases with no additional work. For all four paths, saves a test and jump.
* It turns out that some calls return AEDesc records that are "borrowed",Jack Jansen2003-01-171-0/+1
| | | | | | | the AEDesc data shouldn't be disposed when the Python object is. Added a C call AEDesc_NewBorrowed() to create these objects and a Python method old=AEDesc.AutoDispose(onoff) to change auto-dispose state.
* A. Lloyd Flanagan pointed out a spelling error on c.l.py.Michael W. Hudson2003-01-161-1/+1
|
* Replaced POP() with STACKADJ(-1) on lines where the result wasn't used.Raymond Hettinger2003-01-141-2/+2
| | | | | | The two are semantically equivalent, but the first triggered a compiler warning about an unused variable. Note, the preceding steps had already accessed and decreffed the variable so the reference counts were fine.
* As discussed on python-dev, removed from DUP_TOPX support for theRaymond Hettinger2003-01-101-35/+0
| | | | | | | | parameter being either four or five. Currently, compile.c does not generate calls with a parameter higher than three. May have to be reverted if the second alpha or beta shakes out some other tool generating this op code with a parameter of four or five.
* As discussed briefly on python-dev, add Pending Deprecation WarningNeal Norwitz2003-01-101-3/+5
| | | | | when a string exception is raised. Note that raising string exceptions is deprecated in an exception message.