summaryrefslogtreecommitdiffstats
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
* Simplify and regularize docstrings. Also reformat so that each docstringTim Peters2001-10-171-52/+47
| | | | line fits in reasonable screen width.
* Trimmed trailing whitespace.Tim Peters2001-10-171-62/+62
|
* Removed more comments that didn't make much sense.Tim Peters2001-10-171-17/+1
| | | | Made the presence/absence of a semicolon after macros consistent.
* Removed obsolete comments about confused string refcount tricks (JeremyTim Peters2001-10-171-9/+4
| | | | | | | removed the tricks). Changed the ENTER/LEAVE_ZLIB macros so as not to create a new block (a new block is neither necessary nor helpful).
* Undo needless INCREF chicanery introduced by SF patch #450702.Jeremy Hylton2001-10-161-47/+15
| | | | | | | | | | | | | | Apparently this patch (rev 2.41) replaced all the good old "s#" formats in PyArg_ParseTuple() with "S". Then it did PyString_FromStringAndSize() to get back the values setup by the "s#" format. It also incref'd and decref'd the string obtained by "S" even though the argument tuple had a reference to it. Replace PyString_AsString() calls with PyString_AS_STRING(). A good rule of thumb -- if you never check the return value of PyString_AsString() to see if it's NULL, you ought to be using the macro <wink>.
* Simplify and fix error handling for most cases.Jeremy Hylton2001-10-161-167/+113
| | | | | | | | | | | | | | | | | | Many functions used a local variable called return_error, which was initialized to zero. If an error occurred, it was set to true. Most of the code paths checked were only executed if return_error was false. goto is clearer. The code also seemed to be written under the curious assumption that calling Py_DECREF() on a local variable would assign the variable to NULL. As a result, more of the error-exit code paths returned an object that had a reference count of zero instead of just returning NULL. Fixed the code to explicitly assign NULL after the DECREF. A bit more reformatting, but not much. XXX Need a much better test suite for zlib, since it the current tests don't exercise any of this broken code.
* More reformatting.Jeremy Hylton2001-10-161-51/+50
|
* Add zlib_error() helper.Jeremy Hylton2001-10-161-92/+25
| | | | | It sets a ZlibError exception, using the msg from the z_stream pointer if one is available.
* Remove many calls to set MemoryError exceptions.Jeremy Hylton2001-10-161-28/+4
| | | | | When PyString_FromStringAndSize() and _PyString_Resize() fail, they set an exception. There's no need to set a new exception.
* Reformat!Jeremy Hylton2001-10-161-586/+576
| | | | | | Consistently indent 4 spaces. Use whitespace around operators. Put braces in the right places.
* Partial patch from SF #452266, by Jason Petrone.Guido van Rossum2001-10-161-9/+10
| | | | | | 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.)
* [ #403753 ] zlib decompress; uncontrollable memory usageJeremy Hylton2001-10-161-10/+64
| | | | | | | | | | | | | Mostly by Toby Dickenson and Titus Brown. Add an optional argument to a decompression object's decompress() method. The argument specifies the maximum length of the return value. If the uncompressed data exceeds this length, the excess data is stored as the unconsumed_tail attribute. (Not to be confused with unused_data, which is a separate issue.) Difference from SF patch: Default value for unconsumed_tail is "" rather than None. It's simpler if the attribute is always a string.
* Must terminate the Pickler_members[] and Pickler_getsets with NULL.Jeremy Hylton2001-10-161-1/+3
|
* Removed useless code to count the number of calls into the profiler.Fred Drake2001-10-151-51/+177
| | | | | | | | | | | Added support for saving the names of the functions observed into the profile log. Added support for using the profiler to measure coverage without collecting timing information (which is the slow part). Coverage logs can also be substantially smaller than profiling logs where per-line information is being collected. Updated comments on the log format; corrected record type values in some of the record descriptions.
* Better fix for core dumps on recursive objects in fast mode.Jeremy Hylton2001-10-151-32/+64
| | | | | | | | | | | | | | | | | | | Raise ValueError when an object contains an arbitrarily nested reference to itself. (The previous fix just produced invalid pickles.) Solution is very much like Py_ReprEnter() and Py_ReprLeave(): fast_save_enter() and fast_save_leave() that tracks the fast_container limit and keeps a fast_memo of objects currently being pickled. The cost of the solution is moderately expensive for deeply nested structures, but it still seems to be faster than normal pickling, based on tests with deeply nested lists. Once FAST_LIMIT is exceeded, the new code is about twice as slow as fast-mode code that doesn't check for recursion. It's still twice as fast as the normal pickling code. In the absence of deeply nested structures, I couldn't measure a difference.
* Remove a couple of tp_xxx fields that you are not expected toGuido van Rossum2001-10-151-5/+0
| | | | initialize (or use or even know about :-).
* Fix a bunch of warnings reported by Skip.Guido van Rossum2001-10-151-8/+8
| | | | | | | To whoever who changed a bunch of (PyCFunction) casts to (PyNoArgsFunction) in PyMethodDef initializers: don't do that. The cast is to shut the compiler up. The compiler wants the function pointer initializer to be a PyCFunction.
* Very subtle syntax change: in a list comprehension, the testlist inGuido van Rossum2001-10-151-1/+9
| | | | | | | | | | | | | | | "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)+ [',']]
* Test for __sun instead of __sun__, since SUNWspro only defines the latter;Martin v. Löwis2001-10-132-2/+2
| | | | gcc defines both.
* Cast argument to set_panel_userptr to void*. Fixes bug #417240.Martin v. Löwis2001-10-131-1/+1
|
* Speed the Windows code by using native 64-bit int compiler support insteadTim Peters2001-10-131-11/+14
| | | | of calling external functions.
* This compiles on Windows now.Tim Peters2001-10-131-0/+1
|
* My editor can't deal with long backslash-continued strings. Changed 'em.Tim Peters2001-10-131-48/+49
| | | | | This still doesn't compile on Windows, but at least I have a shot at fixing that now.
* Get hotshot closer to compiling on Windows.Tim Peters2001-10-121-3/+13
| | | | | Still broken: GETTIMEOFDAY. This macro obviously isn't being defined on Windows, so there's logic errors here I'd rather Fred untangled.
* The HotShot core: look, ma, no hands!Fred Drake2001-10-121-0/+1368
|
* Use double curly braces for the generation0/1/2 initializers, to shutGuido van Rossum2001-10-121-3/+3
| | | | up GCC warnings.
* PySocket_getaddrinfo(): fix two refcount bugs, both having to do withGuido van Rossum2001-10-121-3/+6
| | | | | | | | | | | a misunderstanding of the refcont behavior of the 'O' format code in PyArg_ParseTuple() and Py_BuildValue(), respectively. - pobj is only a borrowed reference, so should *not* be DECREF'ed at the end. This was the cause of SF bug #470635. - The Py_BuildValue() call would leak the object produced by makesockaddr(). (I found this by eyeballing the code.)
* Progress on SF bug #466175 and general cleanup.Jeremy Hylton2001-10-121-187/+197
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a fast_container member to Picklerobject. If fast is true, then fast_container counts the depth of nested container calls. If the depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the normal checks occur. This approach is much like the approach for prevent stack overflow for comparison and reprs of recursive objects (e.g. [[...]]). - Fast container used for save_list(), save_dict(), and save_inst(). XXX Not clear which other save_xxx() functions should use it. Make Picklerobject into new-style types, using PyObject_GenericGetAttr() and PyObject_GenericSetAttr(). - Use PyMemberDef for binary and fast members - Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and PicklingError. XXX Not all of these seem like they need to use getset, but it's not clear why the old getattr() and setattr() had such odd semantics. One change is that the getvalue() attribute will exist on all Picklers, not just list-based picklers; I think this is a more rationale interface. There is a long laundry list of other changes: - Remove unused #defines for PyList_SET_ITEM() etc. - Make some of the indentation consistent - Replace uses of cPickle_PyMapping_HasKey() where the first argument is self->memo with calls to PyDict_GetItem(), because self->memo must be a dictionary. - Don't bother to check if cPickle_PyMapping_HasKey() returns < 0, because it can only return 0 or 1. - Replace uses of PyObject_CallObject() with PyObject_Call(), when we can guarantee that the argument tuple is really a tuple. Performance impacts of these changes: - 5% speedup for normal pickling - No change to fast-mode pickling. XXX Really need tests for all the features in cPickle that aren't in pickle.
* SF bug [#467145] Python 2.2a4 build problem on HPUX 11.0.Tim Peters2001-10-111-56/+56
| | | | | | | | | | | | | | The platform requires 8-byte alignment for doubles, but the GC header was 12 bytes and that threw off the natural alignment of the double members of a subtype of complex. The fix puts the GC header into a union with a double as the other member, to force no-looser-than double alignment of GC headers. On boxes that require 8-byte alignment for doubles, this may add pad bytes to the GC header accordingly; ditto for platforms that *prefer* 8-byte alignment for doubles. On platforms that don't care, it shouldn't change the memory layout (because the size of the old GC header is certainly greater than the size of a double on all platforms, so unioning with a double shouldn't change size or alignment on such boxes).
* Use PySocket_Err() instead of PyErr_SetFromErrno().Jeremy Hylton2001-10-111-3/+2
| | | | The former does the right thing on Windows, the latter does not.
* Commit parts of SF patch #462759Jeremy Hylton2001-10-111-68/+68
| | | | | | | | | | | | | | | Use #define X509_NAME_MAXLEN for server/issuer length on an SSL object. Update doc strings for socket.ssl() and ssl methods read() and write(). PySSL_SSLwrite(): Check return value and raise exception on error. Use int for len instead of size_t. (All the function the size_t obj was passed to our from expected an int!) PySSL_SSLread(): Check return value of PyArg_ParseTuple()! More robust checks of return values from SSL_read().
* Convert socket methods to use METH_O and METH_NOARGS where possible.Jeremy Hylton2001-10-111-50/+39
|
* Add a bunch of SSL error constantsJeremy Hylton2001-10-111-0/+12
|
* Lots of code reorganization with a few small API changes.Jeremy Hylton2001-10-101-45/+113
| | | | | | | | | | | | | | | | | | | | | | Change all the local names that start with SSL to start with PySSL. The OpenSSL library defines lots of calls that start with "SSL_". The calls for Python's SSL objects also started with "SSL_". This choice made it really confusing to figure out which calls were to the library and which calls were local to the file. Add PySSL_SetError() that sets an exception based on the information from SSL_get_error(). This function will eventually replace all the calls that set it with an error message that is based on the name of the call that failed rather than the reason it failed. (Example: If SSL_connect() failed it used to report "SSL_connect error" now it will offer a specific message about why SSL_connect failed.) XXX It might be helpful to augment the error message generated below with the name of the SSL function that generated the error. I expect it's obvious most of the time. Remove several unnecessary INCREFs in the module's constructor call. PyDict_SetItem() and friends do the INCREF for you.
* Do simple error checking before doing any SSL calls.Jeremy Hylton2001-10-101-5/+5
|
* USe PyObject_SetString() instead of PyObject_SetObject() in newSSLObject().Jeremy Hylton2001-10-101-14/+9
|
* In newSSLObject(), initialize the various members of an SSLObject to NULL.Jeremy Hylton2001-10-101-2/+8
| | | | | | | In SSL_dealloc(), free/dealloc them only if they're non-NULL. Fixes some obvious core dumps, but not sure yet if there are more semantics to the SSL calls that would affect the dealloc.
* A bit of reformatting to match the standard styleJeremy Hylton2001-10-101-7/+7
|
* Fix two memory leaks in socket.ssl().Jeremy Hylton2001-10-101-39/+29
| | | | | | | | | | | | | | | | | | | | | | | | XXX [1] These changes aren't tested very thoroughly, because regrtest doesn't do any SSL tests. I've done some trivial tests on my own, but don't really know how to use the key and cert files. In one case, an SSL-level error causes Python to dump core. I'll get the fixed in the next round of changes. XXX [2] The checkin removes the x_attr member of the SSLObject struct. I'm not sure if this is kosher for backwards compatibility at the binary level. Perhaps its safer to keep the member but keep it assigned to NULL. And the leaks? newSSLObject() called PyDict_New(), stored the result in x_attr without checking it, and later stored NULL in x_attr without doing anything to the dict. So the dict always leaks. There is no further reference to x_attr, so I just removed it completely. The error cases in newSSLObject() passed the return value of PyString_FromString() directly to PyErr_SetObject(). PyErr_SetObject() expects a borrowed reference, so the string leaked.
* Update URL. Fixes bug #468118.Martin v. Löwis2001-10-091-1/+1
|
* Add additional fields to Xxo_Type declaration. Fixes bug #469250.Martin v. Löwis2001-10-091-0/+31
|
* Guido suggests, and I agree, to insist that SIZEOF_VOID_P be a power of 2.Tim Peters2001-10-071-12/+4
| | | | | | This simplifies the rounding in _PyObject_VAR_SIZE, allows to restore the pre-rounding calling sequence, and allows some nice little simplifications in its callers. I'm still making it return a size_t, though.
* _PyObject_VAR_SIZE: always round up to a multiple-of-pointer-size value.Tim Peters2001-10-061-14/+21
| | | | | | | | | | | | | | | | | As Guido suggested, this makes the new subclassing code substantially simpler. But the mechanics of doing it w/ C macro semantics are a mess, and _PyObject_VAR_SIZE has a new calling sequence now. Question: The PyObject_NEW_VAR macro appears to be part of the public API. Regardless of what it expands to, the notion that it has to round up the memory it allocates is new, and extensions containing the old PyObject_NEW_VAR macro expansion (which was embedded in the PyObject_NEW_VAR expansion) won't do this rounding. But the rounding isn't actually *needed* except for new-style instances with dict pointers after a variable-length blob of embedded data. So my guess is that we do not need to bump the API version for this (as the rounding isn't needed for anything an extension can do unless it's recompiled anyway). What's your guess?
* Repaired the debug Windows deaths in test_descr, by allocating enoughTim Peters2001-10-061-7/+8
| | | | | | | | | | | | | | pad memory to properly align the __dict__ pointer in all cases. gcmodule.c/objimpl.h, _PyObject_GC_Malloc: + Added a "padding" argument so that this flavor of malloc can allocate enough bytes for alignment padding (it can't know this is needed, but its callers do). typeobject.c, PyType_GenericAlloc: + Allocated enough bytes to align the __dict__ pointer. + Sped and simplified the round-up-to-PTRSIZE logic. + Added blank lines so I could parse the if/else blocks <0.7 wink>.
* _PyObject_GC_Malloc(): split a complicated line in two. As is, there wasTim Peters2001-10-061-2/+3
| | | | | no way to talk the debugger into showing me how many bytes were being allocated.
* Adjust the _weakref module to use the public API for the weak referenceFred Drake2001-10-051-717/+15
| | | | | objects. This is now simply a shim to give weakref.py access to the underlying implementation.
* Fix typo in docstringAndrew M. Kuchling2001-10-051-1/+1
|
* Add chroot call. Implements feature #459267.Martin v. Löwis2001-10-041-0/+15
|
* Add various typecasts (back and forth from char * to unsigned char *)Greg Ward2001-10-041-5/+5
| | | | to make the SGI C compiler happier (bug #445960).
* SF patch [#466877] SIGBREAK is missing from signal module.Tim Peters2001-10-011-0/+5
| | | | Patch from Steve Scott to add SIGBREAK support (unique to Windows).