summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* SF patch #470393 (Jim Ahlstrom): Add missing marshal functionGuido van Rossum2001-10-191-0/+8
| | | | | | | | | | In Include/, marshal.h declares both PyMarshal_ReadLongFromFile() and PyMarshal_ReadShortFromFile(), but the second is missing from marshal.c. [Shouldn't the return type be declared as 'short' instead of 'int'? But 'int' is what was in marshal.h all those years... --Guido]
* Move dlfcn.h block out of NetBSD block, assuming that NetBSD beforeMartin v. Löwis2001-10-181-3/+4
| | | | | 199712 didn't have dlfcn.h, or that it wouldn't conflict with the other stuff defined.
* SF Patch (but with no patch) 472555 Remove trailing common in enumeration.Tim Peters2001-10-181-1/+1
| | | | | Some AIX compiler didn't like the trailing comma at the end of the why_code enum decl.
* Squash compiler wng about signed/unsigned mismatch.Tim Peters2001-10-181-1/+1
|
* First part of SF patch #416704: More robust freeze, by Toby Dickenson.Guido van Rossum2001-10-181-5/+23
| | | | | | | This fixes the behavior reported by SF bug #404545, where a file x.y.py could be imported by the statement "import x.y" when there's a frozen package x (I believe even if x.y also exists as a frozen module).
* Fix the frozen bytecode for __hello__ (betcha didn't know that existedGuido van Rossum2001-10-181-5/+12
| | | | | | | | | | :-). Add a test that prevents the __hello__ bytecode from going stale unnoticed again. The test also tests the loophole noted in SF bug #404545. This test will fail right now; I'll check in the fix in a minute.
* Fix for SF bug [ #471928 ] global made w/nested list comprehensionsJeremy Hylton2001-10-181-19/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The symbol table pass didn't have an explicit case for the list_iter node which is used only for a nested list comprehension. As a result, the target of the list comprehension was treated as a use instead of an assignment. Fix is to add a case to symtable_node() to handle list_iter. Also, rework and document a couple of the subtler implementation issues in the symbol table pass. The symtable_node() switch statement depends on falling through the last several cases, in order to handle some of the more complicated nodes like atom. Add a comment explaining the behavior before the first fall through case. Add a comment /* fall through */ at the end of case so that it is explicitly marked as such. Move the for_stmt case out of the fall through logic, which simplifies both for_stmt and default. (The default used the local variable start to skip the first three nodes of a for_stmt when it fell through.) Rename the flag argument to symtable_assign() to def_flag and add a comment explaining its use: The third argument to symatble_assign() is a flag to be passed to symtable_add_def() if it is eventually called. The flag is useful to specify the particular type of assignment that should be recorded, e.g. an assignment caused by import.
* Patch to bug #472202: Correctly recognize NetBSD before 199712.Martin v. Löwis2001-10-181-2/+5
|
* For debug build, check that the stack pointer never exceeds the stack size.Jeremy Hylton2001-10-171-1/+3
|
* Fix computation of stack depth for classdef and closures.Jeremy Hylton2001-10-171-44/+44
| | | | | | | | | | | | | | | | | | | | | | Also minor tweaks to internal routines. Use PyCF_MASK instead of explicit list of flags. For the MAKE_CLOSURE opcode, the number of items popped off the stack depends on both the oparg and the number of free variables for the code object. Fix the code so it accounts for the free variables. In com_classdef(), record an extra pop to account for the STORE call after the BUILD_CLASS. Get rid of some commented out debugging code in com_push() and com_pop(). Factor string resize logic into helper routine com_check_size(). In com_addbyte(), remove redudant if statement after assert. (They test the same condition.) In several routines, use string macros instead of string functions.
* Fix a bug in the previous checkin. The wrong bootstrap function wasGuido van Rossum2001-10-161-1/+1
| | | | passed to _beginthread().
* SF patch #471852 (anonymous) notes that getattr(obj, name, default)Guido van Rossum2001-10-161-1/+3
| | | | masks any exception, not just AttributeError. Fix this.
* Partial patch from SF #452266, by Jason Petrone.Guido van Rossum2001-10-1612-27/+73
| | | | | | This changes Pythread_start_thread() to return the thread ID, or -1 for an error. (It's technically an incompatible API change, but I doubt anyone calls it.)
* SF patch #471839: Bug when extensions import extensions (Shane Hathaway)Guido van Rossum2001-10-161-2/+3
| | | | | | | | | | | | | | | | | When an extension imports another extension in its initXXX() function, the variable _Py_PackageContext is prematurely reset to NULL. If the outer extension then calls Py_InitModule(), the extension is installed in sys.modules without its package name. The manifestation of this bug is a "SystemError: _PyImport_FixupExtension: module <package>.<extension> not loaded". To fix this, importdl.c just needs to retain the old value of _Py_PackageContext and restore it after the initXXX() method is called. The attached patch does this. This patch applies to Python 2.1.1 and the current CVS.
* Put descr name in "bad memberdescr type" error message.Jeremy Hylton2001-10-161-1/+2
|
* make getarray static - it's only called from ceval.c and is not anSkip Montanaro2001-10-151-1/+1
| | | | extern-able name.
* Very subtle syntax change: in a list comprehension, the testlist inGuido van Rossum2001-10-152-102/+131
| | | | | | | | | | | | | | | "for <var> in <testlist> may no longer be a single test followed by a comma. This solves SF bug #431886. Note that if the testlist contains more than one test, a trailing comma is still allowed, for maximum backward compatibility; but this example is not: [(x, y) for x in range(10), for y in range(10)] ^ The fix involved creating a new nonterminal 'testlist_safe' whose definition doesn't allow the trailing comma if there's only one test: testlist_safe: test [(',' test)+ [',']]
* Do not define _POSIX_THREADS if unistd.h defines it.Martin v. Löwis2001-10-151-1/+1
| | | | Check for pthread_sigmask before using it. Fixes remaining problem in #470781.
* Suppress a bunch of "value computed is not used" warnings when building inFred Drake2001-10-131-2/+2
| | | | debug mode (--with-pydebug).
* SF patch #467455 : Enhanced environment variables, by Toby Dickenson.Guido van Rossum2001-10-121-3/+14
| | | | | | | | | | | | | | | | | | | | | | This patch changes to logic to: if env.var. set and non-empty: if env.var. is an integer: set flag to that integer if flag is zero: # [actually, <= 0 --GvR] set flag to 1 Under this patch, anyone currently using PYTHONVERBOSE=yes will get the same output as before. PYTHONVERBNOSE=2 will generate more verbosity than before. The only unusual case that the following three are still all equivalent: PYTHONVERBOSE=yespleas PYTHONVERBOSE=1 PYTHONVERBOSE=0
* Add SF patch #468347 -- mask signals for non-main pthreads, by Jason Lowe:Guido van Rossum2001-10-121-0/+26
| | | | | | | | | | | | | | | | | | | This patch updates Python/thread_pthread.h to mask all signals for any thread created. This will keep all signals masked for any thread that isn't the initial thread. For Solaris and Linux, the two platforms I was able to test it on, it solves bug #465673 (pthreads need signal protection) and probably will solve bug #219772 (Interactive InterPreter+ Thread -> core dump at exit). I'd be great if this could get some testing on other platforms, especially HP-UX pre 11.00 and post 11.00, as I had to make some guesses for the DCE thread case. AIX is also a concern as I saw some mention of using sigthreadmask() as a pthread_sigmask() equivalent, but this patch doesn't use sigthreadmask(). I don't have access to AIX.
* Undo part of 2.59: 't' case of convertsimple() should not use convertbuffer().Jeremy Hylton2001-10-111-5/+11
| | | | | convertbuffer() uses the buffer interface's getreadbuffer(), but 't' should use getcharbuffer().
* One more place where PyString_AsString() was used after aJeremy Hylton2001-10-101-1/+1
| | | | PyString_Check() had already succeeded.
* Use AS_STRING() following the check and avoid an extra call.Jeremy Hylton2001-10-101-1/+1
|
* Implement isinstance(x, (A, B, ...)). Note that we only allow tuples,Guido van Rossum2001-10-071-2/+4
| | | | | not other sequences (then we'd have to except strings, and we'd still be susceptible to recursive attacks).
* 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.
* Introduced the oddly-missing PyList_CheckExact(), and used it to replaceTim Peters2001-10-051-1/+1
| | | | a hard-coded type check.
* Get rid of unique local ISSTRICTINT macro in favor of std PyInt_CheckExact.Tim Peters2001-10-051-9/+6
|
* Fix bug in profiler modifications detected only in debug builds.Fred Drake2001-10-041-3/+26
| | | | | | | | | The new profiler event stream includes a "return" event even when an exception is being propogated, but the machinery that called the profile hook did not save & restore the exception. In debug mode, the exception was detected during the execution of the profile callback, which did not have the proper internal flags set for the exception. Saving & restoring the exception state solves the problem.
* Remove a couple of unused local variables (bug #445960, compiler warningsGreg Ward2001-10-041-4/+2
| | | | on IRIX 6.5).
* Rationalize the events passed to the profiler (no changes for the tracer).Fred Drake2001-10-042-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | The profiler does not need to know anything about the exception state, so we no longer call it when an exception is raised. We do, however, make sure we *always* call the profiler when we exit a frame. This ensures that timing events are more easily isolated by a profiler and finally clauses that do a lot of work don't have their time mis-allocated. When an exception is propogated out of the frame, the C callback for the profiler now receives a PyTrace_RETURN event with an arg of NULL; the Python-level profile hook function will see a 'return' event with an arg of None. This means that from Python it is impossible for the profiler to determine if the frame exited with an exception or if it returned None, but this doesn't matter for profiling. A C-based profiler could tell the difference, but this doesn't seem important. ceval.c:eval_frame(): Simplify the code in two places so that the profiler is called for every exit from a frame and not for exceptions. sysmodule.c:profile_trampoline(): Make sure we don't expose Python code to NULL; use None instead.
* 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().
* SF bug [#466173] unpack TypeError unclearTim Peters2001-09-301-1/+5
| | | | | | Replaced 3 instances of "iter() of non-sequence" with "iteration over non-sequence". Restored "unpack non-sequence" for stuff like "a, b = 1".
* 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.
* Prevent a NULL pointer from being pushed onto the stack.Jeremy Hylton2001-09-261-1/+5
| | | | | | | | | | | | It's possible for PyErr_NormalizeException() to set the traceback pointer to NULL. I'm not sure how to provoke this directly from Python, although it may be possible. The error occurs when an exception is set using PyErr_SetObject() and another exception occurs while PyErr_NormalizeException() is creating the exception instance. XXX As a result of this change, it's possible for an exception to occur but sys.last_traceback to be left undefined. Not sure if this is a problem.
* Don't swap the arguments to PyFrame_BlockSetup when recreating the recentlyThomas Wouters2001-09-241-2/+2
| | | | | | | | | popped frame-block. What an embarrassing bug! Especially for Jeremy, since he accepted the patch :-) This fixes SF bugs #463359 and #462937, and possibly other, *very* obscure bugs with very deeply nested loops that continue the loop and then break out of it or raise an exception.
* Add optional docstrings to member descriptors. For backwardsGuido van Rossum2001-09-204-213/+235
| | | | | | | | | | | | | | | compatibility, this required all places where an array of "struct memberlist" structures was declared that is referenced from a type's tp_members slot to change the type of the structure to PyMemberDef; "struct memberlist" is now only used by old code that still calls PyMember_Get/Set. The code in PyObject_GenericGetAttr/SetAttr now calls the new APIs PyMember_GetOne/SetOne, which take a PyMemberDef argument. As examples, I added actual docstrings to the attributes of a few types: file, complex, instance method, super, and xxsubtype.spamlist. Also converted the symtable to new style getattr.
* Add support for restricting access based on restricted execution mode.Guido van Rossum2001-09-171-5/+16
| | | | | | Renamed the 'readonly' field to 'flags' and defined some new flag bits: READ_RESTRICTED and WRITE_RESTRICTED, as well as a shortcut RESTRICTED that means both.
* Supply code objects a new-style tp_members slot and tp_getattr impl.Jeremy Hylton2001-09-141-16/+34
| | | | | The chief effects are to make dir() do something useful and supply them with an __class__.
* Get rid of builtin_open() entirely (the C code and docstring, not theTim Peters2001-09-131-20/+3
| | | | | builtin function); Guido pointed out that it could be just another name in the __builtin__ dict for the file constructor now.
* _PyBuiltin_Init(): For clarity, macroize this purely repetitive code.Tim Peters2001-09-131-49/+25
|
* Admit that we'll never add the args for a "call" event to the profileFred Drake2001-09-131-3/+0
| | | | | | and trace functions; this now declares that None will be passed for the "call" event. This closes SF bug/suggestion #460315.
* SF bug [#460467] file objects should be subclassable.Tim Peters2001-09-131-22/+13
| | | | Preliminary support. What's here works, but needs fine-tuning.
* build_class(): one more (hopefully the last) step on the way toGuido van Rossum2001-09-121-14/+21
| | | | | | | | | backwards compatibility. When using the class of the first base as the metaclass, use its __class__ attribute in preference over its ob_type slot. This ensures that we can still use classic classes as metaclasse, as shown in the original "Metaclasses" essay. This also makes all the examples in Demo/metaclasses/ work again (maybe these should be turned into a test suite?).
* Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'Jack Jansen2001-09-101-1/+41
| | | | | | parameter for the return string (as unix pathnames are not limited by the 255 char pstring limit). Implemented the function for MachO-Python, where it returns unix pathnames.
* Improve threading on Solaris, according to SF patch #460269, submittedGuido van Rossum2001-09-101-3/+8
| | | | | | | | | | by bbrox@bbrox.org / lionel.ulmer@free.fr. This adds a configure check and if all goes well turns on the PTHREAD_SCOPE_SYSTEM thread attribute for new threads. This should remove the need to add tiny sleeps at the start of threads to allow other threads to be scheduled.
* Fix core dump in PyArg_ParseTuple() with Unicode arguments.Jeremy Hylton2001-09-101-15/+17
| | | | | | | | | Reported by Fredrik Lundh on python-dev. The conversimple() code that handles Unicode arguments and converts them to the default encoding now calls converterr() with the original Unicode argument instead of the NULL returned by the failed encoding attempt.
* SF bug [#458941] Looks like a unary minus bug.Tim Peters2001-09-071-16/+49
| | | | | | | | | | com_factor(): when a unary minus is attached to a float or imaginary zero, don't optimize the UNARY_MINUS opcode away: the const dict can't distinguish between +0.0 and -0.0, so ended up treating both like the first one added to it. Optimizing UNARY_PLUS away isn't a problem. (BTW, I already uploaded the 2.2a3 Windows installer, and this isn't important enough to delay the release.)
* Rename 'getset' to 'property'.Guido van Rossum2001-09-061-2/+2
|
* Patch #455231: Support ELF properly on OpenBSD.Martin v. Löwis2001-09-051-1/+1
|