Commit Graph

2376 Commits

Author SHA1 Message Date
Fred Drake 0d429e8cdd Convert the ref() and proxy() implementations to use the new
PyArg_UnpackTuple() function (serves as an example and test case).
2001-10-23 21:12:47 +00:00
Fredrik Lundh 6de22ef677 another major speedup: let sre.sub/subn check for escapes in the
template string, and don't call the template compiler if we can
avoid it.
2001-10-22 21:18:08 +00:00
Fredrik Lundh f864aa8fd9 sre.split should return the last segment, even if empty
(sorry, barry)
2001-10-22 06:01:56 +00:00
Neil Schemenauer 2677512fc1 Adding missing "static" declarations (found by "make smelly"). 2001-10-21 22:26:43 +00:00
Fredrik Lundh dac58492aa fixed character set description in docstring (SRE uses Python
strings, not C strings)

removed USE_PYTHON defines, and related sre.py helpers

skip calling the subx helper if the template is callable.
interestingly enough, this means that

	def callback(m):
	    return literal
	result = pattern.sub(callback, string)

is much faster than

	result = pattern.sub(literal, string)
2001-10-21 21:48:30 +00:00
Fredrik Lundh 1296a8d77e sre.Scanner fixes (from Greg Chapman). also added a Scanner sanity
check to the test suite.

added a few missing exception checks in the _sre module
2001-10-21 18:04:11 +00:00
Fredrik Lundh bec95b9d88 rewrote the pattern.sub and pattern.subn methods in C
removed (conceptually flawed) getliteral helper; the new sub/subn code
uses a faster code path for literal replacement strings, but doesn't
(yet) look for literal patterns.

added STATE_OFFSET macro, and use it to convert state.start/ptr to
char indexes
2001-10-21 16:47:57 +00:00
Martin v. Löwis 5b68ce3122 Change clear_handlers argument to indicate whether this is an initialization.
Do not set the Expat handlers if it is. Fixes PyXML bug #473195.
2001-10-21 08:53:52 +00:00
Fredrik Lundh 971e78b55b rewrote the pattern.split method in C
also restored SRE Unicode support for 1.6/2.0/2.1
2001-10-20 17:48:46 +00:00
Andrew M. Kuchling 16e65a023e Add two forgotten 'break' statements
Allow passing strings to the .border() method
Correct some error messages ("1 or 4" -> "1 to 4")
Bump version number
Tweak code formatting
Update my e-mail address
2001-10-20 16:05:52 +00:00
Guido van Rossum cad8fa1501 (Hopefully) fix SF bug #472675: CVS socketmodule now doesn't compile
This appears to be a case of a missing \n\ in a multiline string
literal.
2001-10-19 12:40:40 +00:00
Guido van Rossum c524d952da SF patch #460805 by Chris Gonnerman: Support for unsetenv()
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?)
2001-10-19 01:31:59 +00:00
Guido van Rossum b6c1d5239c SF patch #443759: Add Interface to readline's add_history
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.
2001-10-19 01:18:43 +00:00
Martin v. Löwis 4fe3c27323 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW. 2001-10-18 22:05:36 +00:00
Guido van Rossum a4dc73e246 Don't leave bare newlines in long strings -- VC doesn't like that. 2001-10-18 20:53:15 +00:00
Guido van Rossum 98bf58f1c6 SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
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.)
2001-10-18 20:34:25 +00:00
Guido van Rossum a6535fd40b Shut up warnings for setgroups() on Linux -- you have to #include
<grp.h> it seems.  This requires yet another configure test.
2001-10-18 19:44:10 +00:00
Fredrik Lundh 397a654791 SRE bug #441409:
compile should raise error for non-strings
SRE bug #432570, 448951:
    reset group after failed match

also bumped version number to 2.2.0
2001-10-18 19:30:16 +00:00
Martin v. Löwis 61c5edf6fc Expose setgroups. Fixes feature request #468116. 2001-10-18 04:06:00 +00:00
Jeremy Hylton de80f2efb5 Expose three OpenSSL API calls for dealing with the PRNG.
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.
2001-10-18 00:28:50 +00:00
Jeremy Hylton a25d995ab0 The Python symtable module depends on .h files that setup.py doesn't track. 2001-10-17 13:46:44 +00:00
Jeremy Hylton 771f9146d5 Remove unused convenience routine. 2001-10-17 13:32:02 +00:00
Tim Peters adbd35bbcc Simplify and regularize docstrings. Also reformat so that each docstring
line fits in reasonable screen width.
2001-10-17 04:16:15 +00:00
Tim Peters 977e540e4b Trimmed trailing whitespace. 2001-10-17 03:57:20 +00:00
Tim Peters b1a37c0196 Removed more comments that didn't make much sense.
Made the presence/absence of a semicolon after macros consistent.
2001-10-17 03:56:45 +00:00
Tim Peters 6605c64c83 Removed obsolete comments about confused string refcount tricks (Jeremy
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).
2001-10-17 03:43:54 +00:00
Jeremy Hylton ba3dd9990f Undo needless INCREF chicanery introduced by SF patch #450702.
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>.
2001-10-16 23:26:08 +00:00
Jeremy Hylton 9d620d018c Simplify and fix error handling for most cases.
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.
2001-10-16 23:02:32 +00:00
Jeremy Hylton 4990000077 More reformatting. 2001-10-16 21:59:35 +00:00
Jeremy Hylton 0965e084cd Add zlib_error() helper.
It sets a ZlibError exception, using the msg from the z_stream pointer
if one is available.
2001-10-16 21:56:09 +00:00
Jeremy Hylton 9bc9d66eb1 Remove many calls to set MemoryError exceptions.
When PyString_FromStringAndSize() and _PyString_Resize() fail, they
set an exception.  There's no need to set a new exception.
2001-10-16 21:23:58 +00:00
Jeremy Hylton 9714f99d60 Reformat!
Consistently indent 4 spaces.
Use whitespace around operators.
Put braces in the right places.
2001-10-16 21:19:45 +00:00
Guido van Rossum 3c28863e08 Partial patch from SF #452266, by Jason Petrone.
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.)
2001-10-16 21:13:49 +00:00
Jeremy Hylton 511e2cacc4 [ #403753 ] zlib decompress; uncontrollable memory usage
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.
2001-10-16 20:39:49 +00:00
Jeremy Hylton 3eb46f3a5d Must terminate the Pickler_members[] and Pickler_getsets with NULL. 2001-10-16 17:10:49 +00:00
Fred Drake 30d1c75d15 Removed useless code to count the number of calls into the profiler.
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.
2001-10-15 22:11:02 +00:00
Jeremy Hylton 499ab6a653 Better fix for core dumps on recursive objects in fast mode.
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.
2001-10-15 21:37:58 +00:00
Guido van Rossum 2ef1b8fd97 Remove a couple of tp_xxx fields that you are not expected to
initialize (or use or even know about :-).
2001-10-15 21:24:12 +00:00
Guido van Rossum 17209fcf1f Fix a bunch of warnings reported by Skip.
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.
2001-10-15 21:12:54 +00:00
Guido van Rossum 1c917072ca Very subtle syntax change: in a list comprehension, the testlist in
"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)+ [',']]
2001-10-15 15:44:05 +00:00
Martin v. Löwis 1c07b4b4fb Test for __sun instead of __sun__, since SUNWspro only defines the latter;
gcc defines both.
2001-10-13 09:00:42 +00:00
Martin v. Löwis a38d9169bc Cast argument to set_panel_userptr to void*. Fixes bug #417240. 2001-10-13 08:50:10 +00:00
Tim Peters 7d99ff27e8 Speed the Windows code by using native 64-bit int compiler support instead
of calling external functions.
2001-10-13 07:37:52 +00:00
Tim Peters 1b6e08a25e This compiles on Windows now. 2001-10-13 00:14:28 +00:00
Tim Peters feab23f834 My editor can't deal with long backslash-continued strings. Changed 'em.
This still doesn't compile on Windows, but at least I have a shot at
fixing that now.
2001-10-13 00:11:10 +00:00
Tim Peters 1566a17af5 Get hotshot closer to compiling on Windows.
Still broken:  GETTIMEOFDAY.  This macro obviously isn't being defined
on Windows, so there's logic errors here I'd rather Fred untangled.
2001-10-12 22:08:39 +00:00
Fred Drake 8c081a1584 The HotShot core: look, ma, no hands! 2001-10-12 20:57:55 +00:00
Guido van Rossum bca8c2ebea Use double curly braces for the generation0/1/2 initializers, to shut
up GCC warnings.
2001-10-12 20:52:48 +00:00
Guido van Rossum 716aac0448 PySocket_getaddrinfo(): fix two refcount bugs, both having to do with
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.)
2001-10-12 18:59:27 +00:00
Jeremy Hylton a0fb177be8 Progress on SF bug #466175 and general cleanup.
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.
2001-10-12 04:11:06 +00:00
Tim Peters 9e4ca10ce4 SF bug [#467145] Python 2.2a4 build problem on HPUX 11.0.
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).
2001-10-11 18:31:31 +00:00
Jeremy Hylton e2adc6c205 Use PySocket_Err() instead of PyErr_SetFromErrno().
The former does the right thing on Windows, the latter does not.
2001-10-11 17:27:58 +00:00
Jeremy Hylton ba69936037 Commit parts of SF patch #462759
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().
2001-10-11 17:23:34 +00:00
Jeremy Hylton ae0013d3aa Convert socket methods to use METH_O and METH_NOARGS where possible. 2001-10-11 16:36:35 +00:00
Jeremy Hylton 57ca873c77 Add a bunch of SSL error constants 2001-10-11 00:00:17 +00:00
Jeremy Hylton 5b6ce5a2b5 Lots of code reorganization with a few small API changes.
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.
2001-10-10 23:55:43 +00:00
Jeremy Hylton 22738b9bc1 Do simple error checking before doing any SSL calls. 2001-10-10 22:37:48 +00:00
Jeremy Hylton b0b0bd6cc6 USe PyObject_SetString() instead of PyObject_SetObject() in newSSLObject(). 2001-10-10 22:33:32 +00:00
Jeremy Hylton ec4b545014 In newSSLObject(), initialize the various members of an SSLObject to NULL.
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.
2001-10-10 03:37:05 +00:00
Jeremy Hylton ab0064574b A bit of reformatting to match the standard style 2001-10-10 03:33:24 +00:00
Jeremy Hylton f86d63e4f0 Fix two memory leaks in socket.ssl().
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.
2001-10-10 03:19:39 +00:00
Martin v. Löwis 1dbce44b91 Update URL. Fixes bug #468118. 2001-10-09 10:54:31 +00:00
Martin v. Löwis ffa7aff751 Add additional fields to Xxo_Type declaration. Fixes bug #469250. 2001-10-09 10:46:58 +00:00
Tim Peters f2a67daca2 Guido suggests, and I agree, to insist that SIZEOF_VOID_P be a power of 2.
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.
2001-10-07 03:54:51 +00:00
Tim Peters 6d483d3477 _PyObject_VAR_SIZE: always round up to a multiple-of-pointer-size value.
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?
2001-10-06 21:27:34 +00:00
Tim Peters 406fe3b1c0 Repaired the debug Windows deaths in test_descr, by allocating enough
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>.
2001-10-06 19:04:01 +00:00
Tim Peters 8c18f25850 _PyObject_GC_Malloc(): split a complicated line in two. As is, there was
no way to talk the debugger into showing me how many bytes were being
allocated.
2001-10-06 08:03:20 +00:00
Fred Drake f7f8cad548 Adjust the _weakref module to use the public API for the weak reference
objects.  This is now simply a shim to give weakref.py access to the
underlying implementation.
2001-10-05 22:00:24 +00:00
Andrew M. Kuchling 38300c631a Fix typo in docstring 2001-10-05 12:24:15 +00:00
Martin v. Löwis 244edc8985 Add chroot call. Implements feature #459267. 2001-10-04 22:44:26 +00:00
Greg Ward a645b30294 Add various typecasts (back and forth from char * to unsigned char *)
to make the SGI C compiler happier (bug #445960).
2001-10-04 14:54:53 +00:00
Tim Peters 1ce3cf7749 SF patch [#466877] SIGBREAK is missing from signal module.
Patch from Steve Scott to add SIGBREAK support (unique to Windows).
2001-10-01 17:58:40 +00:00
Martin v. Löwis 0daad598d0 Patch #462122: add readline startup and pre_event hooks. 2001-09-30 21:09:59 +00:00
Martin v. Löwis 16dc7f44b1 Patch #462190, patch #464070: Support quoted printable in the binascii module.
Decode and encode underscores for header style encoding. Fixes bug #463996.
2001-09-30 20:32:11 +00:00
Tim Peters d38b1c74f3 SF [#466125] PyLong_AsLongLong works for any integer.
Generalize PyLong_AsLongLong to accept int arguments too.  The real point
is so that PyArg_ParseTuple's 'L' code does too.  That code was
undocumented (AFAICT), so documented it.
2001-09-30 05:09:37 +00:00
Guido van Rossum e296cedef9 Be more rigorous about making pathnames absolute, to address SF bug
#424002.

Refactor init_path_from_argv0() and rename to copy_absolute(); add
absolutize() which does the same in-place.

Clean up whitespace (leading tabs -> spaces, delete trailing
spaces/tabs).
2001-09-28 20:00:29 +00:00
Jeremy Hylton ede049b2d3 Add tests for new PyErr_NormalizeException() behavior
Add raise_exception() to the _testcapi module.  It isn't a test, but
the C API exists only to support test_exceptions.  raise_exception()
takes two arguments -- an exception class and an integer specifying
how many arguments it should be called with.

test_exceptions uses BadException() to test the interpreter's behavior
when there is a problem instantiating the exception.  test_capi1()
calls it with too many arguments.  test_capi2() causes an exception to
be raised in the Python code of the constructor.
2001-09-26 20:01:13 +00:00
Guido van Rossum 10b164a32d SF patch #459385 (Norman Vine): time.timezone fix for Cygwin.
Also did some whitespace normalization.
2001-09-25 13:59:01 +00:00
Marc-André Lemburg e47df7a211 StringIO patch #462596: let's [c]StringIO accept read buffers on
input to .write() too.
2001-09-24 17:34:52 +00:00
Martin v. Löwis 287620f50d Patch #463421: speed up md5 module with real memcpy/set. 2001-09-24 17:14:40 +00:00
Martin v. Löwis 894258cebe Reactivate participation of expat parsers in GC. Fixes bug #462710. 2001-09-23 10:20:10 +00:00
Barry Warsaw 3e8be722d9 I_getiter(): Function for the tp_iter slot of Itype so that
cStringIO's can participate in the iterator protocol.

Fill the Itype.tp_iter slot with I_getiter()
2001-09-22 04:36:49 +00:00
Guido van Rossum 32d34c809f Add optional docstrings to getset descriptors. Fortunately, there's
no backwards compatibility to worry about, so I just pushed the
'closure' struct member to the back -- it's never used in the current
code base (I may eliminate it, but that's more work because the getter
and setter signatures would have to change.)

As examples, I added actual docstrings to the getset attributes of a
few types: file.closed, xxsubtype.spamdict.state.
2001-09-20 21:45:26 +00:00
Guido van Rossum 6f7993765a Add optional docstrings to member descriptors. For backwards
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.
2001-09-20 20:46:19 +00:00
Guido van Rossum 461591eb17 PyLocale_setlocale(): silence compiler warning about free() of a const
char *.
2001-09-20 19:18:30 +00:00
Marc-André Lemburg c60e6f7771 Patch #435971: UTF-7 codec by Brian Quinlan. 2001-09-20 10:35:46 +00:00
Martin v. Löwis 7090ed16d7 Include ctype.h after Python.h. 2001-09-19 10:37:50 +00:00
Martin v. Löwis c57428d3a0 Patch to bug #461753: Allow None in ExternalEntityParserCreate. 2001-09-19 09:55:09 +00:00
Fredrik Lundh 59b68656f8 fixed #449964: sre.sub raises an exception if the template contains a
\g<x> group reference followed by a character escape

(also restructured a few things on the way to fixing #449000)
2001-09-18 20:55:24 +00:00
Fredrik Lundh 21009b9c6f an SRE bugfix a day keeps Guido away...
#462270: sub-tle difference between pre.sub and sre.sub.  PRE ignored
an empty match at the previous location, SRE didn't.

also synced with Secret Labs "sreopen" codebase.
2001-09-18 18:47:09 +00:00
Andrew M. Kuchling fda3c3ddae [Patch #462255, from Jason Tishler] Re-enables building the resouce
module on the Cygwin platform.
2001-09-17 16:19:16 +00:00
Tim Peters 0891ac017d The 'p' (Pascal string) pack code acts unreasonably when the string size
and count exceed 255.  Changed to preserve as much of the string as
possible (instead of count%256 characters).
2001-09-15 02:35:15 +00:00
Martin v. Löwis caef93d82c Silence warnings about passing unsigned char** as char**. 2001-09-08 16:23:34 +00:00
Martin v. Löwis 3bd8c1ee47 Patch #450702: allow threads when calling into zlib, protect usage of
the module in multiple threads with a global lock.
2001-09-07 16:27:31 +00:00
Martin v. Löwis 39e0c5daeb Fix compiler warnings. This closes some of the #458880 problem. 2001-09-07 16:10:00 +00:00
Martin v. Löwis 387c547fd3 Revert parts of patch #453627, documenting the resulting test failures
instead.
2001-09-06 08:16:17 +00:00
Tim Peters 6e13a562ae Enable large file support on Win32 systems.
Curious:  the MS docs say stati64 etc are supported even on Win95, but
Win95 doesn't support a filesystem that allows partitions > 2 Gb.

test_largefile:  This was opening its test file in text mode.  I have no
idea how that worked under Win64, but it sure needs binary mode on Win98.
BTW, on Win98 test_largefile runs quickly (under a second).
2001-09-06 00:32:15 +00:00
Tim Peters a40c793d06 Rework the way we try to check for libm overflow, given that C99 no longer
requires that errno ever get set, and it looks like glibc is already
playing that game.  New rules:

+ Never use HUGE_VAL.  Use the new Py_HUGE_VAL instead.

+ Never believe errno.  If overflow is the only thing you're interested in,
  use the new Py_OVERFLOWED(x) macro.  If you're interested in any libm
  errors, use the new Py_SET_ERANGE_IF_OVERFLOW(x) macro, which attempts
  to set errno the way C89 said it worked.

Unfortunately, none of these are reliable, but they work on Windows and I
*expect* under glibc too.
2001-09-05 22:36:56 +00:00
Martin v. Löwis 7c82a3e0fc Patch #449815: Set filesystemencoding based on CODESET. 2001-09-05 17:09:48 +00:00
Martin v. Löwis 655c9557f6 Patch #453627: Define the following macros when compiling on a UnixWare 7.x system:
SCO_ATAN2_BUG, SCO_ACCEPT_BUG, and STRICT_SYSV_CURSES.
Work aroudn a bug in the SCO UnixWare atan2() implementation.
2001-09-05 14:45:54 +00:00