]> granicus.if.org Git - python/log
python
24 years agoSF patch 419176 from MvL; fixed bug 418977
Jeremy Hylton [Tue, 8 May 2001 04:08:59 +0000 (04:08 +0000)]
SF patch 419176 from MvL; fixed bug 418977

Two errors in dict_to_map() helper used by PyFrame_LocalsToFast().

24 years agoRemove unused variable
Jeremy Hylton [Tue, 8 May 2001 04:00:45 +0000 (04:00 +0000)]
Remove unused variable

24 years agoThis is a test showing SF bug 422177. It won't trigger until I check in
Tim Peters [Tue, 8 May 2001 03:58:01 +0000 (03:58 +0000)]
This is a test showing SF bug 422177.  It won't trigger until I check in
another change (to test_import.py, which simply imports the new file).  I'm
checking this piece in now, though, to make it easier to distribute a patch
for x-platform checking.

24 years agoSF bug #422108 - Error in rich comparisons.
Tim Peters [Mon, 7 May 2001 20:53:51 +0000 (20:53 +0000)]
SF bug #422108 - Error in rich comparisons.
2.1.1 bugfix candidate too.
Fix a bad (albeit unlikely) return value in try_rich_to_3way_compare().
Also document do_cmp()'s return values.

24 years agoMichael Hudson <mwh21@cam.ac.uk>:
Fred Drake [Mon, 7 May 2001 17:55:35 +0000 (17:55 +0000)]
Michael Hudson <mwh21@cam.ac.uk>:

This patch does several things to termios:

(1) changes all functions to be METH_VARARGS
(2) changes all functions to be able to take a file object as the
    first parameter, as per

http://mail.python.org/pipermail/python-dev/2001-February/012701.html

(3) give better error messages
(4) removes a bunch of comments that just repeat the docstrings
(5) #includes <termio.h> before #including <sys/ioctl.h> so more
    #constants are actually #defined.
(6) a couple of docstring tweaks

I have tested this minimally (i.e. it builds, and
doesn't blow up too embarassingly) on OSF1/alpha and
on one of the sf compile farm's solaris boxes, and
rather more comprehansively on my linux/x86 box.

It still needs to be tested on all the other platforms
we build termios on.

This closes the code portion of SF patch #417081.

24 years agoHmm... better add a version annotation for the Iterator Protocol section.
Fred Drake [Mon, 7 May 2001 17:47:07 +0000 (17:47 +0000)]
Hmm... better add a version annotation for the Iterator Protocol section.

24 years agoAdded documentation for PyIter_Check() and PyIter_Next().
Fred Drake [Mon, 7 May 2001 17:42:18 +0000 (17:42 +0000)]
Added documentation for PyIter_Check() and PyIter_Next().

Wrapped a long line.

24 years agoGeneralize zip() to work with iterators.
Tim Peters [Sun, 6 May 2001 01:05:02 +0000 (01:05 +0000)]
Generalize zip() to work with iterators.
NEEDS DOC CHANGES.
More AttributeErrors transmuted into TypeErrors, in test_b2.py, and,
again, this strikes me as a good thing.
This checkin completes the iterator generalization work that obviously
needed to be done.  Can anyone think of others that should be changed?

24 years agoGet rid of silly 5am "del" stmts.
Tim Peters [Sat, 5 May 2001 21:36:52 +0000 (21:36 +0000)]
Get rid of silly 5am "del" stmts.

24 years agoReimplement PySequence_Contains() and instance_contains(), so they work
Tim Peters [Sat, 5 May 2001 21:05:01 +0000 (21:05 +0000)]
Reimplement PySequence_Contains() and instance_contains(), so they work
safely together and don't duplicate logic (the common logic was factored
out into new private API function _PySequence_IterContains()).
Visible change:
    some_complex_number  in  some_instance
no longer blows up if some_instance has __getitem__ but neither
__contains__ nor __iter__.  test_iter changed to ensure that remains true.

24 years agoSkeletal version; I'm checking this in now so I can keep a list of changes,
Andrew M. Kuchling [Sat, 5 May 2001 16:37:29 +0000 (16:37 +0000)]
Skeletal version; I'm checking this in now so I can keep a list of changes,
   but don't plan on actually writing any text until, ooh, say, July or
   thereabouts.

24 years agoGeneralize PySequence_Count() (operator.countOf) to work with iterators.
Tim Peters [Sat, 5 May 2001 11:33:43 +0000 (11:33 +0000)]
Generalize PySequence_Count() (operator.countOf) to work with iterators.

24 years agoRemove redundant line.
Tim Peters [Sat, 5 May 2001 10:14:34 +0000 (10:14 +0000)]
Remove redundant line.

24 years agoMake 'x in y' and 'x not in y' (PySequence_Contains) play nice w/ iterators.
Tim Peters [Sat, 5 May 2001 10:06:17 +0000 (10:06 +0000)]
Make 'x in y' and 'x not in y' (PySequence_Contains) play nice w/ iterators.
NEEDS DOC CHANGES
A few more AttributeErrors turned into TypeErrors, but in test_contains
this time.
The full story for instance objects is pretty much unexplainable, because
instance_contains() tries its own flavor of iteration-based containment
testing first, and PySequence_Contains doesn't get a chance at it unless
instance_contains() blows up.  A consequence is that
    some_complex_number in some_instance
dies with a TypeError unless some_instance.__class__ defines __iter__ but
does not define __getitem__.

24 years agoMake unicode.join() work nice with iterators. This also required a change
Tim Peters [Sat, 5 May 2001 05:36:48 +0000 (05:36 +0000)]
Make unicode.join() work nice with iterators.  This also required a change
to string.join(), so that when the latter figures out in midstream that
it really needs unicode.join() instead, unicode.join() can actually get
all the sequence elements (i.e., there's no guarantee that the sequence
passed to string.join() can be iterated over *again* by unicode.join(),
so string.join() must not pass on the original sequence object anymore).

24 years agoMark string.join() as done. Turns out string_join() works "for free" now,
Tim Peters [Sat, 5 May 2001 04:24:43 +0000 (04:24 +0000)]
Mark string.join() as done.  Turns out string_join() works "for free" now,
because PySequence_Fast() started working for free as soon as
PySequence_Tuple() learned how to work with iterators.  For some reason
unicode.join() still doesn't work, though.

24 years agoFix a tiny and unlikely memory leak. Was there before too, and actually
Tim Peters [Sat, 5 May 2001 04:10:25 +0000 (04:10 +0000)]
Fix a tiny and unlikely memory leak.  Was there before too, and actually
several of these turned up and got fixed during the iteration crusade.

24 years agoGeneralize tuple() to work nicely with iterators.
Tim Peters [Sat, 5 May 2001 03:56:37 +0000 (03:56 +0000)]
Generalize tuple() to work nicely with iterators.
NEEDS DOC CHANGES.
This one surprised me!  While I expected tuple() to be a no-brainer, turns
out it's actually dripping with consequences:
1. It will *allow* the popular PySequence_Fast() to work with any iterable
   object (code for that not yet checked in, but should be trivial).
2. It caused two std tests to fail.  This because some places used
   PyTuple_Sequence() (the C spelling of tuple()) as an indirect way to test
   whether something *is* a sequence.  But tuple() code only looked for the
   existence of sq->item to determine that, and e.g. an instance passed
   that test whether or not it supported the other operations tuple()
   needed (e.g., __len__).  So some things the tests *expected* to fail
   with an AttributeError now fail with a TypeError instead.  This looks
   like an improvement to me; e.g., test_coercion used to produce 559
   TypeErrors and 2 AttributeErrors, and now they're all TypeErrors.  The
   error details are more informative too, because the places calling this
   were *looking* for TypeErrors in order to replace the generic tuple()
   "not a sequence" msg with their own more specific text, and
   AttributeErrors snuck by that.

24 years agoMake PyIter_Next() a little smarter (wrt its knowledge of iterator
Tim Peters [Sat, 5 May 2001 00:14:56 +0000 (00:14 +0000)]
Make PyIter_Next() a little smarter (wrt its knowledge of iterator
internals) so clients can be a lot dumber (wrt their knowledge).

24 years agoMake the license GPL-compatible.
Guido van Rossum [Fri, 4 May 2001 18:49:06 +0000 (18:49 +0000)]
Make the license GPL-compatible.

24 years agoAdd TODO item about x in y -- this should use iterators too, IMO.
Guido van Rossum [Fri, 4 May 2001 13:40:18 +0000 (13:40 +0000)]
Add TODO item about x in y -- this should use iterators too, IMO.

24 years agoAdded reminders to make some remaining functions iterator-friendly. Feel
Tim Peters [Fri, 4 May 2001 04:43:42 +0000 (04:43 +0000)]
Added reminders to make some remaining functions iterator-friendly.  Feel
free to do one!

24 years agoGeneralize reduce() to work with iterators.
Tim Peters [Fri, 4 May 2001 04:39:21 +0000 (04:39 +0000)]
Generalize reduce() to work with iterators.
NEEDS DOC CHANGES.

24 years agoPurge redundant cut&paste line.
Tim Peters [Thu, 3 May 2001 23:58:47 +0000 (23:58 +0000)]
Purge redundant cut&paste line.

24 years agoGeneralize map() to work with iterators.
Tim Peters [Thu, 3 May 2001 23:54:49 +0000 (23:54 +0000)]
Generalize map() to work with iterators.
NEEDS DOC CHANGES.
Possibly contentious:  The first time s.next() yields StopIteration (for
a given map argument s) is the last time map() *tries* s.next().  That
is, if other sequence args are longer, s will never again contribute
anything but None values to the result, even if trying s.next() again
could yield another result.  This is the same behavior map() used to have
wrt IndexError, so it's the only way to be wholly backward-compatible.
I'm not a fan of letting StopIteration mean "try again later" anyway.

24 years agoThe weakref support in PyObject_InitVar() as well; this should have come out
Fred Drake [Thu, 3 May 2001 20:04:33 +0000 (20:04 +0000)]
The weakref support in PyObject_InitVar() as well; this should have come out
at the same time as it did from PyObject_Init() .

24 years agoRemove unnecessary intialization for the case of weakly-referencable objects;
Fred Drake [Thu, 3 May 2001 19:44:50 +0000 (19:44 +0000)]
Remove unnecessary intialization for the case of weakly-referencable objects;
the code necessary to accomplish this is simpler and faster if confined to
the object implementations, so we only do this there.

This causes no behaviorial changes beyond a (very slight) speedup.

24 years agoRemove an obsolete comment and a "return" before fallig off the end of a
Fred Drake [Thu, 3 May 2001 16:05:46 +0000 (16:05 +0000)]
Remove an obsolete comment and a "return" before fallig off the end of a
void function.

24 years agoSince Py_TPFLAGS_HAVE_WEAKREFS is set in Py_TPFLAGS_DEFAULT, it does not
Fred Drake [Thu, 3 May 2001 16:04:13 +0000 (16:04 +0000)]
Since Py_TPFLAGS_HAVE_WEAKREFS is set in Py_TPFLAGS_DEFAULT, it does not
need to be specified in the type structures independently.  The flag
exists only for binary compatibility.

This is a "source cleanliness" issue and introduces no behavioral changes.

24 years agoRemove redundant copy+paste code.
Tim Peters [Thu, 3 May 2001 07:09:25 +0000 (07:09 +0000)]
Remove redundant copy+paste code.

24 years agoGeneralize max(seq) and min(seq) to work with iterators.
Tim Peters [Thu, 3 May 2001 07:00:32 +0000 (07:00 +0000)]
Generalize max(seq) and min(seq) to work with iterators.
NEEDS DOC CHANGES.

24 years agoInteractiveInterpreter.showsyntaxerror():
Fred Drake [Thu, 3 May 2001 04:58:49 +0000 (04:58 +0000)]
InteractiveInterpreter.showsyntaxerror():
    When replacing the exception object, be sure we stuff the new value
    in sys.last_value (which we already did for the original value).

24 years agoAdded support for .__contains__(), .__iter__(), .iterkeys().
Fred Drake [Thu, 3 May 2001 04:55:47 +0000 (04:55 +0000)]
Added support for .__contains__(), .__iter__(), .iterkeys().

24 years agoAdded support for .iteritems(), .iterkeys(), .itervalues().
Fred Drake [Thu, 3 May 2001 04:54:41 +0000 (04:54 +0000)]
Added support for .iteritems(), .iterkeys(), .itervalues().

24 years agoThe general iteration support is part of 2.2, not 2.1 -- fixed the version
Fred Drake [Thu, 3 May 2001 04:39:10 +0000 (04:39 +0000)]
The general iteration support is part of 2.2, not 2.1 -- fixed the version
annotations!

Also fixed a typo noted by Neil S.

24 years agoAdd documentation for the StopIteration exception.
Fred Drake [Thu, 3 May 2001 04:30:45 +0000 (04:30 +0000)]
Add documentation for the StopIteration exception.

24 years agoState that Mailbox objects are iterator objects.
Fred Drake [Wed, 2 May 2001 20:22:12 +0000 (20:22 +0000)]
State that Mailbox objects are iterator objects.

24 years agoMake the Mailbox objects support iteration -- they already had the
Fred Drake [Wed, 2 May 2001 20:20:53 +0000 (20:20 +0000)]
Make the Mailbox objects support iteration -- they already had the
appropriate next() method, and this is what people really want to do with
these objects in practice.

24 years agoUpdate the filter() and list() descriptions to include information about
Fred Drake [Wed, 2 May 2001 20:19:19 +0000 (20:19 +0000)]
Update the filter() and list() descriptions to include information about
the support for containers and iteration.

24 years agoAdded section describing the iterator protocol.
Fred Drake [Wed, 2 May 2001 20:18:03 +0000 (20:18 +0000)]
Added section describing the iterator protocol.

24 years agoAdded new parser markers 'et' and 'et#' which do not recode string
Marc-André Lemburg [Wed, 2 May 2001 17:16:16 +0000 (17:16 +0000)]
Added new parser markers 'et' and 'et#' which do not recode string
objects but instead assume that they use the requested encoding.

This is needed on Windows to enable opening files by passing in
Unicode file names.

24 years agoMchael Hudson pointed out that the code for detecting changes in
Guido van Rossum [Wed, 2 May 2001 15:13:44 +0000 (15:13 +0000)]
Mchael Hudson pointed out that the code for detecting changes in
dictionary size was comparing ma_size, the hash table size, which is
always a power of two, rather than ma_used, wich changes on each
insertion or deletion.  Fixed this.

24 years agoFix for bug #417030: "print '%*s' fails for unicode string"
Marc-André Lemburg [Wed, 2 May 2001 14:21:53 +0000 (14:21 +0000)]
Fix for bug #417030: "print '%*s' fails for unicode string"

24 years agoGeneralize filter(f, seq) to work with iterators. This also generalizes
Tim Peters [Wed, 2 May 2001 07:39:38 +0000 (07:39 +0000)]
Generalize filter(f, seq) to work with iterators.  This also generalizes
filter() to no longer insist that len(seq) be defined.
NEEDS DOC CHANGES.

24 years agoPlug a memory leak in list(), when appending to the result list.
Tim Peters [Wed, 2 May 2001 07:12:39 +0000 (07:12 +0000)]
Plug a memory leak in list(), when appending to the result list.

24 years agoWhitespace normalization.
Tim Peters [Wed, 2 May 2001 05:54:44 +0000 (05:54 +0000)]
Whitespace normalization.

24 years agoAdded tests for Weak*Dictionary iterator support.
Fred Drake [Wed, 2 May 2001 05:44:22 +0000 (05:44 +0000)]
Added tests for Weak*Dictionary iterator support.

Refactored some object initialization to be more reusable.

24 years agoAdded iterator support to the Weak*Dictionary classes.
Fred Drake [Wed, 2 May 2001 05:43:09 +0000 (05:43 +0000)]
Added iterator support to the Weak*Dictionary classes.

24 years agoAdd more news about iterators.
Guido van Rossum [Tue, 1 May 2001 20:54:30 +0000 (20:54 +0000)]
Add more news about iterators.

24 years agoGeneralize list(seq) to work with iterators. This also generalizes list()
Tim Peters [Tue, 1 May 2001 20:45:31 +0000 (20:45 +0000)]
Generalize list(seq) to work with iterators.  This also generalizes list()
to no longer insist that len(seq) be defined.
NEEDS DOC CHANGES.
This is meant to be a model for how other functions of this ilk (max,
filter, etc) can be generalized similarly.  Feel encouraged to grab your
favorite and convert it!
Note some cute consequences:
    list(file) == file.readlines() == list(file.xreadlines())
    list(dict) == dict.keys()
    list(dict.iteritems()) = dict.items()
    list(xrange(i, j, k)) == range(i, j, k)

24 years agoDiscard a misleading comment about iter_iternext().
Guido van Rossum [Tue, 1 May 2001 17:01:25 +0000 (17:01 +0000)]
Discard a misleading comment about iter_iternext().

24 years agoPrinting objects to a real file still wasn't done right: if the
Guido van Rossum [Tue, 1 May 2001 16:53:37 +0000 (16:53 +0000)]
Printing objects to a real file still wasn't done right: if the
object's type didn't define tp_print, there were still cases where the
full "print uses str() which falls back to repr()" semantics weren't
honored.  This resulted in

    >>> print None
    <None object at 0x80bd674>
    >>> print type(u'')
    <type object at 0x80c0a80>

Fixed this by always using the appropriate PyObject_Repr() or
PyObject_Str() call, rather than trying to emulate what they would do.

Also simplified PyObject_Str() to always fall back on PyObject_Repr()
when tp_str is not defined (rather than making an extra check for
instances with a __str__ method).  And got rid of the special case for
strings.

24 years agoAdd a proper implementation for the tp_str slot (returning self, of
Guido van Rossum [Tue, 1 May 2001 16:51:53 +0000 (16:51 +0000)]
Add a proper implementation for the tp_str slot (returning self, of
course), so I can get rid of the special case for strings in
PyObject_Str().

24 years agoAdd experimental iterkeys(), itervalues(), iteritems() to dict
Guido van Rossum [Tue, 1 May 2001 12:10:21 +0000 (12:10 +0000)]
Add experimental iterkeys(), itervalues(), iteritems() to dict
objects.

Tests show that iteritems() is 5-10% faster than iterating over the
dict and extracting the value with dict[key].

24 years agoWell darnit! The innocuous fix I made to PyObject_Print() caused
Guido van Rossum [Mon, 30 Apr 2001 14:39:18 +0000 (14:39 +0000)]
Well darnit!  The innocuous fix I made to PyObject_Print() caused
printing of instances not to look for __str__().  Fix this.

24 years agoSF bug #417093: Case sensitive import: dir and .py file w/ same name
Tim Peters [Sun, 29 Apr 2001 22:21:25 +0000 (22:21 +0000)]
SF bug #417093: Case sensitive import: dir and .py file w/ same name
Directory containing
    Spam.py
    spam/__init__.py
Then "import Spam" caused a SystemError, because code checking for
the existence of "Spam/__init__.py" finds it on a case-insensitive
filesystem, but then bails because the directory it finds it in
doesn't match case, and then old code assumed that was still an error
even though it isn't anymore.  Changed the code to just continue
looking in this case (instead of calling it an error).  So
    import Spam
and
    import spam
both work now.

24 years agoFix buglet reported on c.l.py: map(fnc, file.xreadlines()) blows up.
Tim Peters [Sat, 28 Apr 2001 08:20:22 +0000 (08:20 +0000)]
Fix buglet reported on c.l.py:  map(fnc, file.xreadlines()) blows up.
Also a 2.1 bugfix candidate (am I supposed to do something with those?).
Took away map()'s insistence that sequences support __len__, and cleaned
up the convoluted code that made it *look* like it really cared about
__len__ (in fact the old ->len field was only *used* as a flag bit, as
the main loop only looked at its sign bit, setting the field to -1 when
IndexError got raised; renamed the field to ->saw_IndexError instead).

24 years agoA different approach to the problem reported in
Tim Peters [Sat, 28 Apr 2001 05:38:26 +0000 (05:38 +0000)]
A different approach to the problem reported in
Patch #419651: Metrowerks on Mac adds 0x itself
C std says %#x and %#X conversion of 0 do not add the 0x/0X base marker.
Metrowerks apparently does.  Mark Favas reported the same bug under a
Compaq compiler on Tru64 Unix, but no other libc broken in this respect
is known (known to be OK under MSVC and gcc).
So just try the damn thing at runtime and see what the platform does.
Note that we've always had bugs here, but never knew it before because
a relevant test case didn't exist before 2.1.

24 years ago(Adding this to the trunk as well.)
Guido van Rossum [Fri, 27 Apr 2001 21:35:01 +0000 (21:35 +0000)]
(Adding this to the trunk as well.)

Fix a very old flaw in PyObject_Print().  Amazing!  When an object
type defines tp_str but not tp_repr, 'print x' to a real file
object would not call the tp_str slot but rather print a default style
representation: <foo object at 0x....>.  This even though 'print x' to
a file-like-object would correctly call the tp_str slot.

24 years agoGot rid of the whole event filtering mess again, I can't get it to work. Simply disab...
Jack Jansen [Fri, 27 Apr 2001 20:43:27 +0000 (20:43 +0000)]
Got rid of the whole event filtering mess again, I can't get it to work. Simply disabling the Tk event handling hook in _tkinter is not as nice, but at least it works.

24 years agoFix 2.1 nested scopes crash reported by Evan Simpson
Jeremy Hylton [Fri, 27 Apr 2001 02:29:40 +0000 (02:29 +0000)]
Fix 2.1 nested scopes crash reported by Evan Simpson

The new test case demonstrates the bug.  Be more careful in
symtable_resolve_free() to add a var to cells or frees only if it
won't be added under some other rule.

XXX Add new assertion that will catch this bug.

24 years agoimproved error message-- names the type of the unexpected object
Jeremy Hylton [Fri, 27 Apr 2001 02:25:33 +0000 (02:25 +0000)]
improved error message-- names the type of the unexpected object

24 years agoApparently the code to forestall Tk eating events was too aggressive (Tk user input...
Jack Jansen [Thu, 26 Apr 2001 13:22:33 +0000 (13:22 +0000)]
Apparently the code to forestall Tk eating events was too aggressive (Tk user input stopped working). Fixed (I hope:-).

24 years agoAdded more help, and recovery from misspelled sort key arguments.
Eric S. Raymond [Thu, 26 Apr 2001 07:32:38 +0000 (07:32 +0000)]
Added more help, and recovery from misspelled sort key arguments.

24 years agoFiles for 2.1 distribution.
Jack Jansen [Wed, 25 Apr 2001 22:11:24 +0000 (22:11 +0000)]
Files for 2.1 distribution.

24 years agoCheck RefCon backpointer to python object with IsPointerValid() before dereferencing...
Jack Jansen [Wed, 25 Apr 2001 22:09:29 +0000 (22:09 +0000)]
Check RefCon backpointer to python object with IsPointerValid() before dereferencing it (carbon only).

24 years agoUpdated copyright info (which was long due).
Jack Jansen [Wed, 25 Apr 2001 22:08:12 +0000 (22:08 +0000)]
Updated copyright info (which was long due).

24 years ago- Raise console window on input. Fixes Carbon hang.
Jack Jansen [Wed, 25 Apr 2001 22:07:42 +0000 (22:07 +0000)]
- Raise console window on input. Fixes Carbon hang.

24 years ago- Raise console window on input. Fixes Carbon hang.
Jack Jansen [Wed, 25 Apr 2001 22:07:27 +0000 (22:07 +0000)]
- Raise console window on input. Fixes Carbon hang.
- Better handling of menu bar save/restore.
- Override abort() so it honours the "keep console window" flag.

24 years agoDon't crash if InfoScrap doesn't exist (as is the case in Carbon).
Jack Jansen [Wed, 25 Apr 2001 22:05:36 +0000 (22:05 +0000)]
Don't crash if InfoScrap doesn't exist (as is the case in Carbon).

24 years agoCorrect two floating-point representations printed by the interpreter in
Fred Drake [Wed, 25 Apr 2001 21:03:20 +0000 (21:03 +0000)]
Correct two floating-point representations printed by the interpreter in
interactive examples.  Error noted by Dinu Gherman.

24 years agoUpdate test to accomodate the change to the namespace_separator parameter
Fred Drake [Wed, 25 Apr 2001 16:03:54 +0000 (16:03 +0000)]
Update test to accomodate the change to the namespace_separator parameter
of ParserCreate().

Added assignment tests for the ordered_attributes and specified_attributes
values, similar to the checks for the returns_unicode attribute.

24 years agoParserCreate(): Allow an empty string for the namespace_separator argument;
Fred Drake [Wed, 25 Apr 2001 16:01:30 +0000 (16:01 +0000)]
ParserCreate():  Allow an empty string for the namespace_separator argument;
    while not generally a good idea, this is used by RDF users, and works
    to implement RDF-style namespace+localname concatenation as defined
    in the RDF specifications.  (This also corrects a backwards-compatibility
    bug.)

Be more conservative while clearing out handlers; set the slot in the
self->handlers array to NULL before DECREFing the callback.

Still more adjustments to make the code style internally consistent.

24 years agoSF bug 418615: regular expression bug in pipes.py.
Tim Peters [Wed, 25 Apr 2001 03:43:14 +0000 (03:43 +0000)]
SF bug 418615: regular expression bug in pipes.py.
Obviously bad regexps, spotted by Jeffery Collins.

HELP!  I can't run this on Windows, and the module test() function
probably doesn't work on anyone's box.  Could a Unixoid please write
an at least minimal working test and add it to the std test suite?

24 years agoSF bug 418296: WinMain.c should use WIN32_LEAN_AND_MEAN.
Tim Peters [Tue, 24 Apr 2001 05:16:29 +0000 (05:16 +0000)]
SF bug 418296: WinMain.c should use WIN32_LEAN_AND_MEAN.
I believe Kevin Rodgers here!  The old WINDOWS_LEAN_AND_MEAN has, AFAICT,
always been wrong.

24 years agoFix typo in docstring
Andrew M. Kuchling [Mon, 23 Apr 2001 17:13:03 +0000 (17:13 +0000)]
Fix typo in docstring

24 years agoBump version # for final release
Andrew M. Kuchling [Mon, 23 Apr 2001 16:01:06 +0000 (16:01 +0000)]
Bump version # for final release

24 years agoThis patch originated from an idea by Martin v. Loewis who submitted a
Marc-André Lemburg [Mon, 23 Apr 2001 14:44:21 +0000 (14:44 +0000)]
This patch originated from an idea by Martin v. Loewis who submitted a
patch for sharing single character Unicode objects.

Martin's patch had to be reworked in a number of ways to take Unicode
resizing into consideration as well. Here's what the updated patch
implements:

* Single character Unicode strings in the Latin-1 range are shared
  (not only ASCII chars as in Martin's original patch).

* The ASCII and Latin-1 codecs make use of this optimization,
  providing a noticable speedup for single character strings. Most
  Unicode methods can use the optimization as well (by virtue
  of using PyUnicode_FromUnicode()).

* Some code cleanup was done (replacing memcpy with Py_UNICODE_COPY)

* The PyUnicode_Resize() can now also handle the case of resizing
  unicode_empty which previously resulted in an error.

* Modified the internal API _PyUnicode_Resize() and
  the public PyUnicode_Resize() API to handle references to
  shared objects correctly. The _PyUnicode_Resize() signature
  changed due to this.

* Callers of PyUnicode_FromUnicode() may now only modify the Unicode
  object contents of the returned object in case they called the API
  with NULL as content template.

Note that even though this patch passes the regression tests, there
may still be subtle bugs in the sharing code.

24 years agoMondo changes to the iterator stuff, without changing how Python code
Guido van Rossum [Mon, 23 Apr 2001 14:08:49 +0000 (14:08 +0000)]
Mondo changes to the iterator stuff, without changing how Python code
sees it (test_iter.py is unchanged).

- Added a tp_iternext slot, which calls the iterator's next() method;
  this is much faster for built-in iterators over built-in types
  such as lists and dicts, speeding up pybench's ForLoop with about
  25% compared to Python 2.1.  (Now there's a good argument for
  iterators. ;-)

- Renamed the built-in sequence iterator SeqIter, affecting the C API
  functions for it.  (This frees up the PyIter prefix for generic
  iterator operations.)

- Added PyIter_Check(obj), which checks that obj's type has a
  tp_iternext slot and that the proper feature flag is set.

- Added PyIter_Next(obj) which calls the tp_iternext slot.  It has a
  somewhat complex return condition due to the need for speed: when it
  returns NULL, it may not have set an exception condition, meaning
  the iterator is exhausted; when the exception StopIteration is set
  (or a derived exception class), it means the same thing; any other
  exception means some other error occurred.

24 years agoAt the suggestion of Peter Funk, document 'key in dict' and 'key not
Guido van Rossum [Mon, 23 Apr 2001 13:22:59 +0000 (13:22 +0000)]
At the suggestion of Peter Funk, document 'key in dict' and 'key not
in dict' after has_key(), with a \versionadded{2.2} note.

24 years agoUpdate publish-to-SourceForge scripts to automatically determine if the
Fred Drake [Sun, 22 Apr 2001 06:20:31 +0000 (06:20 +0000)]
Update publish-to-SourceForge scripts to automatically determine if the
branch is the head (development) branch or a maintenance brach, and use
the appropriate target directory for each.

24 years agoOnly document <file>.xreadlines() once; added version annotation.
Fred Drake [Sun, 22 Apr 2001 01:56:51 +0000 (01:56 +0000)]
Only document <file>.xreadlines() once; added version annotation.

This closes SF bug #417943.

24 years agoProcess Setup* files with makesetup in the same order as the makefile.
Neil Schemenauer [Sat, 21 Apr 2001 17:41:16 +0000 (17:41 +0000)]
Process Setup* files with makesetup in the same order as the makefile.

24 years agoAdd test suite for iterators.
Guido van Rossum [Sat, 21 Apr 2001 13:33:54 +0000 (13:33 +0000)]
Add test suite for iterators.

24 years agoOops, forgot to merge this from the iter-branch to the trunk.
Guido van Rossum [Sat, 21 Apr 2001 13:20:18 +0000 (13:20 +0000)]
Oops, forgot to merge this from the iter-branch to the trunk.

This adds "for line in file" iteration, as promised.

24 years agoGive UserDict new __contains__ and __iter__ methods.
Tim Peters [Sat, 21 Apr 2001 09:13:15 +0000 (09:13 +0000)]
Give UserDict new __contains__ and __iter__ methods.

24 years agoencode(): Handle Latin-1 input characters better.
Fred Drake [Sat, 21 Apr 2001 06:01:53 +0000 (06:01 +0000)]
encode():  Handle Latin-1 input characters better.

24 years agoAdd support for <memberline/> (needs markup improvement!).
Fred Drake [Sat, 21 Apr 2001 06:00:51 +0000 (06:00 +0000)]
Add support for <memberline/> (needs markup improvement!).

Update <versionadded/> to recent addition of optional explanatory text;
make the explanation text take the same attribute name for both
<versionadded/> and <versionchanged/>.

24 years agoFix a number of minor markup errors.
Fred Drake [Sat, 21 Apr 2001 05:56:06 +0000 (05:56 +0000)]
Fix a number of minor markup errors.

24 years agoThe (fairly recent) \textasciicircum is not supported by LaTeX2HTML; add
Fred Drake [Sat, 21 Apr 2001 05:48:07 +0000 (05:48 +0000)]
The (fairly recent) \textasciicircum is not supported by LaTeX2HTML; add
support for it here.

24 years agoSF bug #417508: 'hypot' not found with Borland C++Build.
Tim Peters [Sat, 21 Apr 2001 03:20:47 +0000 (03:20 +0000)]
SF bug #417508: 'hypot' not found with Borland C++Build.

24 years agoSF but #417587: compiler warnings compiling 2.1.
Tim Peters [Sat, 21 Apr 2001 02:46:11 +0000 (02:46 +0000)]
SF but #417587: compiler warnings compiling 2.1.
Repaired *some* of the SGI compiler warnings Sjoerd Mullender reported.

24 years agoTeach Windows about new iterobject.c.
Tim Peters [Fri, 20 Apr 2001 21:21:28 +0000 (21:21 +0000)]
Teach Windows about new iterobject.c.

24 years agoAdding iterobject.[ch], which were accidentally not added. Sorry\!
Guido van Rossum [Fri, 20 Apr 2001 21:06:46 +0000 (21:06 +0000)]
Adding iterobject.[ch], which were accidentally not added.  Sorry\!

24 years agoIterators phase 1. This comprises:
Guido van Rossum [Fri, 20 Apr 2001 19:13:02 +0000 (19:13 +0000)]
Iterators phase 1.  This comprises:

new slot tp_iter in type object, plus new flag Py_TPFLAGS_HAVE_ITER
new C API PyObject_GetIter(), calls tp_iter
new builtin iter(), with two forms: iter(obj), and iter(function, sentinel)
new internal object types iterobject and calliterobject
new exception StopIteration
new opcodes for "for" loops, GET_ITER and FOR_ITER (also supported by dis.py)
new magic number for .pyc files
new special method for instances: __iter__() returns an iterator
iteration over dictionaries: "for x in dict" iterates over the keys
iteration over files: "for x in file" iterates over lines

TODO:

documentation
test suite
decide whether to use a different way to spell iter(function, sentinal)
decide whether "for key in dict" is a good idea
use iterators in map/filter/reduce, min/max, and elsewhere (in/not in?)
speed tuning (make next() a slot tp_next???)

24 years agodispatcher.__repr__() was unprepared to handle the address for a Unix
Jeremy Hylton [Fri, 20 Apr 2001 19:04:55 +0000 (19:04 +0000)]
dispatcher.__repr__() was unprepared to handle the address for a Unix
domain socket.  Fix that and make the error message for failures a
little more helpful by including the class name.

24 years agoOops. Removed dictiter_new decl that wasn't supposed to go in yet.
Guido van Rossum [Fri, 20 Apr 2001 16:52:06 +0000 (16:52 +0000)]
Oops.  Removed dictiter_new decl that wasn't supposed to go in yet.

24 years agoImplement, test and document "key in dict" and "key not in dict".
Guido van Rossum [Fri, 20 Apr 2001 16:50:40 +0000 (16:50 +0000)]
Implement, test and document "key in dict" and "key not in dict".

I know some people don't like this -- if it's really controversial,
I'll take it out again.  (If it's only Alex Martelli who doesn't like
it, that doesn't count as "real controversial" though. :-)

That's why this is a separate checkin from the iterators stuff I'm
about to check in next.

24 years agoCVS patch 416248: 2.1c1 unicodeobject: unused vrbl cleanup, from Mark Favas.
Tim Peters [Thu, 19 Apr 2001 21:55:14 +0000 (21:55 +0000)]
CVS patch 416248: 2.1c1 unicodeobject: unused vrbl cleanup, from Mark Favas.

24 years agoRevert previous checkin, which caused test_unicodedata to fail.
Jeremy Hylton [Thu, 19 Apr 2001 16:43:49 +0000 (16:43 +0000)]
Revert previous checkin, which caused test_unicodedata to fail.