summaryrefslogtreecommitdiffstats
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
* SF patch #460805 by Chris Gonnerman: Support for unsetenv()Guido van Rossum2001-10-191-0/+34
| | | | | | | | This adds unsetenv to posix, and uses it in the __delitem__ method of os.environ. (XXX Should we change the preferred name for putenv to setenv, for consistency?)
* SF patch #443759: Add Interface to readline's add_historyGuido van Rossum2001-10-191-0/+18
| | | | | | | | | | | | | | This was submitted by Moshe, but apparently he's too busy to check it in himself. He wrote: Here is a function in GNU readline called add_history, which is used to manage the history list. Though Python uses this function internally, it does not expose it to the Python programmer. This patch adds direct interface to this function with documentation. This could be used by friendly modules to "seed" the history with commands.
* Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.Martin v. Löwis2001-10-181-0/+17
|
* Don't leave bare newlines in long strings -- VC doesn't like that.Guido van Rossum2001-10-181-3/+3
|
* SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.Guido van Rossum2001-10-182-78/+227
| | | | | | | | | | | | | | | | | This is a big one, touching lots of files. Some of the platforms aren't tested yet. Briefly, this changes the return value of the os/posix functions stat(), fstat(), statvfs(), fstatvfs(), and the time functions localtime(), gmtime(), and strptime() from tuples into pseudo-sequences. When accessed as a sequence, they behave exactly as before. But they also have attributes like st_mtime or tm_year. The stat return value, moreover, has a few platform-specific attributes that are not available through the sequence interface (because everybody expects the sequence to have a fixed length, these couldn't be added there). If your platform's struct stat doesn't define st_blksize, st_blocks or st_rdev, they won't be accessible from Python either. (Still missing is a documentation update.)
* Shut up warnings for setgroups() on Linux -- you have to #includeGuido van Rossum2001-10-181-0/+5
| | | | <grp.h> it seems. This requires yet another configure test.
* SRE bug #441409:Fredrik Lundh2001-10-181-1/+3
| | | | | | | | compile should raise error for non-strings SRE bug #432570, 448951: reset group after failed match also bumped version number to 2.2.0
* Expose setgroups. Fixes feature request #468116.Martin v. Löwis2001-10-181-0/+48
|
* Expose three OpenSSL API calls for dealing with the PRNG.Jeremy Hylton2001-10-181-0/+67
| | | | | | | | | | | | | | | | | Quoth the OpenSSL RAND_add man page: OpenSSL makes sure that the PRNG state is unique for each thread. On systems that provide /dev/urandom, the randomness device is used to seed the PRNG transparently. However, on all other systems, the application is responsible for seeding the PRNG by calling RAND_add(), RAND_egd(3) or RAND_load_file(3). I decided to expose RAND_add() because it's general and RAND_egd() because it's a useful special case. RAND_load_file() didn't seem to offer much over RAND_add(), so I skipped it. Also supplied RAND_status() which returns true if the PRNG is seeded and false if not.
* The Python symtable module depends on .h files that setup.py doesn't track.Jeremy Hylton2001-10-171-0/+3
|
* Remove unused convenience routine.Jeremy Hylton2001-10-171-19/+0
|
* 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.