]> granicus.if.org Git - python/log
python
22 years ago(Most of) SF patch 601369 (Christos Georgiou): obmalloc,structmodule:
Guido van Rossum [Tue, 3 Sep 2002 18:42:21 +0000 (18:42 +0000)]
(Most of) SF patch 601369 (Christos Georgiou): obmalloc,structmodule:
64bit, big endian (issue 2 only).

This adds a bunch of memcpy calls via a temporary variable to avoid
alignment errors.  That's needed for some platforms.

22 years agoFix for SF bug 601077 by Zack Weinberg.
Guido van Rossum [Tue, 3 Sep 2002 16:36:17 +0000 (16:36 +0000)]
Fix for SF bug 601077 by Zack Weinberg.

The new execvpe code would sometimes do the wrong thing when a
non-executable file existed earlier in the path and an executable file
of the same name existed later in the path.  This patch restores the
proper behavior (which is to execute the second file).  When only a
non-executable file exists, the correct error is still reported.

22 years agoRemoved reliance on gcc/C99 extension.
Tim Peters [Tue, 3 Sep 2002 15:39:58 +0000 (15:39 +0000)]
Removed reliance on gcc/C99 extension.

22 years agoCheck whether a string resize is necessary at the end
Walter Dörwald [Tue, 3 Sep 2002 13:53:40 +0000 (13:53 +0000)]
Check whether a string resize is necessary at the end
of PyString_DecodeEscape(). This prevents a call to
_PyString_Resize() for the empty string, which would
result in a PyErr_BadInternalCall(), because the
empty string has more than one reference.

This closes SF bug http://www.python.org/sf/603937

22 years agoexpose PYTHON_API_VERSION macro as sys.api_version. Closes patch # 601456.
Skip Montanaro [Tue, 3 Sep 2002 13:25:17 +0000 (13:25 +0000)]
expose PYTHON_API_VERSION macro as sys.api_version.  Closes patch # 601456.

22 years agoIgnore encoding declarations inside strings. Fixes #603509.
Martin v. Löwis [Tue, 3 Sep 2002 11:52:44 +0000 (11:52 +0000)]
Ignore encoding declarations inside strings. Fixes #603509.

22 years agoAdd reminder about PEP293
Andrew M. Kuchling [Tue, 3 Sep 2002 00:53:21 +0000 (00:53 +0000)]
Add reminder about PEP293

22 years ago(Re)Apply Sourceforge Python patch 520483, Sourceforge Idlefork patch
Kurt B. Kaiser [Mon, 2 Sep 2002 21:29:40 +0000 (21:29 +0000)]
(Re)Apply Sourceforge Python patch 520483, Sourceforge Idlefork patch
521908 (again) to MAIN

The patch applied by Steven was inadvertently reverted during the
transition to GRPC.

Python 2.3a0 (#3, May  8 2002, 23:37:01)
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "copyright", "credits" or "license" for more information.
GRPC IDLE Fork 0.8.2
>>> print u'\xbfQu\xe9 pas\xf3?'
¿Qué pasó?
Modified Files:
OutputWindow.py

22 years agoCheck string for NULL before using it to format the error message.
Walter Dörwald [Mon, 2 Sep 2002 18:22:32 +0000 (18:22 +0000)]
Check string for NULL before using it to format the error message.
(Spotted by Neal Norwitz)

22 years agoRemoved bogus PyUnicodeTranslateError_GetEncoding, as
Walter Dörwald [Mon, 2 Sep 2002 16:41:55 +0000 (16:41 +0000)]
Removed bogus PyUnicodeTranslateError_GetEncoding, as
UnicodeTranslateError doesn't have an encoding attribute.
(Spotted by Neal Norwitz)

22 years agoLimit the length of attribute names in exception messages
Walter Dörwald [Mon, 2 Sep 2002 16:10:06 +0000 (16:10 +0000)]
Limit the length of attribute names in exception messages
to prevent buffer overflows (spotted by Neal Norwitz).

22 years agoMinor change for symmetry with PyXML: PyDoc_STR should not include
Fred Drake [Mon, 2 Sep 2002 15:54:06 +0000 (15:54 +0000)]
Minor change for symmetry with PyXML:  PyDoc_STR should not include
the "safety" parentheses since some older compilers refuse to compile
the module then, claiming that static initializers are non-constant.

This doesn't actually make any difference for Python, since these
definitions are not used when compiling with a version of Python that
already defines the PyDoc_* macros.

22 years agoPEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald [Mon, 2 Sep 2002 13:14:32 +0000 (13:14 +0000)]
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)

22 years agoGenerate pythonw.sh on the fly.
Jack Jansen [Mon, 2 Sep 2002 12:29:11 +0000 (12:29 +0000)]
Generate pythonw.sh on the fly.
Use the build python for as many things as possible.

22 years agoPass -x badsyntax to compileall.
Jack Jansen [Mon, 2 Sep 2002 12:16:00 +0000 (12:16 +0000)]
Pass -x badsyntax to compileall.
Tweaks to make builds work for non-standard dstroot.

22 years ago_structure(): Use .get_content_type()
Barry Warsaw [Sun, 1 Sep 2002 21:04:43 +0000 (21:04 +0000)]
_structure(): Use .get_content_type()

22 years agoSF bug 601775 - some int results that should be bool.
Guido van Rossum [Sun, 1 Sep 2002 15:06:28 +0000 (15:06 +0000)]
SF bug 601775 - some int results that should be bool.

22 years agoAdded comparison functions to dict proxies.
Raymond Hettinger [Sat, 31 Aug 2002 15:51:04 +0000 (15:51 +0000)]
Added comparison functions to dict proxies.
Now all non-mutating dict methods are in the proxy also.
Inspired by SF bug #602232,

22 years agoBecause MWH changed the bytecode again, moved the magic number *back*
Guido van Rossum [Sat, 31 Aug 2002 15:16:14 +0000 (15:16 +0000)]
Because MWH changed the bytecode again, moved the magic number *back*
to 62011.  This should get the snake-farm to throw away its old .pyc
files, amongst others.

22 years agoImplemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen [Sat, 31 Aug 2002 01:25:17 +0000 (01:25 +0000)]
Implemented the Help menu. The Python manual can be viewed (if installed)
and the selection can be looked up, and so can the Carbon manual. From the
help menu you can also get to the online documentation, the Python website
and the MacPython page.

Untested in MacPython-OS9.

22 years agoIf there's an environment variable PYTHONIDEPATH it points to the IDE
Jack Jansen [Sat, 31 Aug 2002 01:22:37 +0000 (01:22 +0000)]
If there's an environment variable PYTHONIDEPATH it points to the IDE
folder. This allows running the IDE from the source tree on OSX.

22 years agoMenuID's are signed.
Jack Jansen [Sat, 31 Aug 2002 01:20:53 +0000 (01:20 +0000)]
MenuID's are signed.

22 years agoTypecode for AHTOCType was wrong. Fixed.
Jack Jansen [Fri, 30 Aug 2002 23:02:09 +0000 (23:02 +0000)]
Typecode for AHTOCType was wrong. Fixed.

22 years agoInitialize self._helpmenu earlier, so we can use gethelpmenu() while
Jack Jansen [Fri, 30 Aug 2002 23:01:28 +0000 (23:01 +0000)]
Initialize self._helpmenu earlier, so we can use gethelpmenu() while
building the user menus.

22 years agoFix for Jaguar: use ln for installing symlinks, install no longer works.
Jack Jansen [Fri, 30 Aug 2002 15:14:02 +0000 (15:14 +0000)]
Fix for Jaguar: use ln for installing symlinks, install no longer works.
Fix for sh: use : in stead of an empty then clause in an if.

22 years agoFurther SET_LINENO reomval fixes. See comments in patch #587933.
Michael W. Hudson [Fri, 30 Aug 2002 13:09:51 +0000 (13:09 +0000)]
Further SET_LINENO reomval fixes.  See comments in patch #587933.

Use a slightly different strategy to determine when not to call the line
trace function.  This removes the need for the RETURN_NONE opcode, so
that's gone again.  Update docs and comments to match.

Thanks to Neal and Armin!

Also add a test suite.  This should have come with the original patch...

22 years agoOn Jaguar the default mode for files in the installed product is 444 (or 555)
Jack Jansen [Fri, 30 Aug 2002 12:56:08 +0000 (12:56 +0000)]
On Jaguar the default mode for files in the installed product is 444 (or 555)
in stead of 644 (755). This makes a subsequent install fail. Changed
the INSTALL_MODE_FLAG to fix this.

22 years agoAdded support for the help menu. Application.gethelpmenu() will return
Jack Jansen [Thu, 29 Aug 2002 22:04:15 +0000 (22:04 +0000)]
Added support for the help menu. Application.gethelpmenu() will return
it.

Also fixed menu IDs to be signed in do_menudispatch. this is an incompatible
change, but I don't think it'll hurt anyone.

22 years agoRevived the Carbon.Help module, but implementing the MacHelp API in stead
Jack Jansen [Thu, 29 Aug 2002 21:09:00 +0000 (21:09 +0000)]
Revived the Carbon.Help module, but implementing the MacHelp API in stead
of the defunct Balloons API. Help tags are TBD, but at least this gives
us access to the help menu.

22 years agoSF #561244: micro optimizations, builtins cannot be NULL, so use Py_INCREF
Neal Norwitz [Thu, 29 Aug 2002 20:25:46 +0000 (20:25 +0000)]
SF #561244: micro optimizations, builtins cannot be NULL, so use Py_INCREF

22 years agoDon't copy the documentation when using Python.app as an applet template.
Jack Jansen [Thu, 29 Aug 2002 20:20:24 +0000 (20:20 +0000)]
Don't copy the documentation when using Python.app as an applet template.

22 years agoMany hopefully benign style clean ups. Still passes the test suite of
Barry Warsaw [Thu, 29 Aug 2002 16:24:50 +0000 (16:24 +0000)]
Many hopefully benign style clean ups.  Still passes the test suite of
course.

22 years agostrptime(): The code that was adding 12 to PM hours was incorrect
Barry Warsaw [Thu, 29 Aug 2002 15:29:49 +0000 (15:29 +0000)]
strptime(): The code that was adding 12 to PM hours was incorrect
because it added it to 12 PM too.  12 PM should be hour 12 not hour
24.

Also cleaned up a minor style nit.  There are more style problems in
this file that I'll clean up next (but I didn't want them to overwhelm
the substance of this fix).

22 years agoThe test I saw failing this morning just happened to be run at 8am
Barry Warsaw [Thu, 29 Aug 2002 15:25:04 +0000 (15:25 +0000)]
The test I saw failing this morning just happened to be run at 8am
localtime, which in -0400 is 12 noon GMT.  The bug boiled down to
broken conversion of 12 PM to hour 12 for the '%I %p' format string.

Added a test for this specific condition: Strptime12AMPMTests.  Fix to
_strptime.py coming momentarily.

22 years agoSped _update().
Raymond Hettinger [Thu, 29 Aug 2002 15:13:50 +0000 (15:13 +0000)]
Sped _update().
Uses the fast update() method when a dictionary is available.

22 years agoUndo Barry's change. This file is not imported, it's fed as input to
Guido van Rossum [Thu, 29 Aug 2002 15:10:30 +0000 (15:10 +0000)]
Undo Barry's change.  This file is not imported, it's fed as input to
the tokenize module by test_tokenize.py.  The FutureWarnings only
appeared during installation, and I've figured out a way to suppress
those in a different way.

22 years agoSuppress warnings when byte-compiling the installed library modules.
Guido van Rossum [Thu, 29 Aug 2002 15:04:37 +0000 (15:04 +0000)]
Suppress warnings when byte-compiling the installed library modules.
This seems the sanest thing to do.

22 years agoRestore the hex/oct constant tests that Barry commented out for fear
Guido van Rossum [Thu, 29 Aug 2002 14:57:26 +0000 (14:57 +0000)]
Restore the hex/oct constant tests that Barry commented out for fear
of FutureWarnings.  Added a comment explaining the situation.

22 years agocomplex() was the only numeric constructor that created a new instance
Raymond Hettinger [Thu, 29 Aug 2002 14:22:51 +0000 (14:22 +0000)]
complex() was the only numeric constructor that created a new instance
when given its own type as an argument.

22 years agoFixed three exceptions in the Plain integers test, although I'm not
Barry Warsaw [Thu, 29 Aug 2002 13:09:47 +0000 (13:09 +0000)]
Fixed three exceptions in the Plain integers test, although I'm not
sure these are the best fixes.

- Test maxint-1 against the negative octal constant -020000000000

- Comment out the tests for oct -1 and hex -1, since 037777777777 and
  0xffffffff raise FutureWarnings now and in Python 2.4 those
  constants will produce positive values, not negative values.  So the
  existing test seems to test something that won't be true in 2.4.

22 years agoThe test_tokenize output has changed slightly, by the addition of some
Barry Warsaw [Thu, 29 Aug 2002 12:56:59 +0000 (12:56 +0000)]
The test_tokenize output has changed slightly, by the addition of some
trailing `L's.

22 years agoDistutils-based script by Bill Fancher to download the Python documentation
Jack Jansen [Wed, 28 Aug 2002 22:22:10 +0000 (22:22 +0000)]
Distutils-based script by Bill Fancher to download the Python documentation
HTML tarball and use it to create a documentation tree readable and
searchable with Apple Help Viewer. The documentation also shows up in
Project Builder (if you add Python.framework to your project).

22 years ago- Install a symlink to the documentation (which lives in the framework)
Jack Jansen [Wed, 28 Aug 2002 21:27:02 +0000 (21:27 +0000)]
- Install a symlink to the documentation (which lives in the framework)
  in Python.app, and refer to it in Info.plist. This makes Apple Help
  Viewer recognize the Python documentation.
- Changed the externally visible name of Python.app to "Python" (was PythonW).

22 years agoDistutils-based script by Bill Fancher to download the Python documentation
Jack Jansen [Wed, 28 Aug 2002 21:23:53 +0000 (21:23 +0000)]
Distutils-based script by Bill Fancher to download the Python documentation
HTML tarball and use it to create a documentation tree readable and
searchable with Apple Help Viewer. The documentation also shows up in
Project Builder (if you add Python.framework to your project).

22 years agoThis file never made it to the repository, somehow.
Jack Jansen [Wed, 28 Aug 2002 21:19:26 +0000 (21:19 +0000)]
This file never made it to the repository, somehow.

22 years agoThese were regenerated some time ago (with ascii chars only and
Jack Jansen [Wed, 28 Aug 2002 21:18:37 +0000 (21:18 +0000)]
These were regenerated some time ago (with ascii chars only and
fully qualified imports) but somehow not checked in yet.

22 years agoInterface to Apple Help Viewer.
Jack Jansen [Wed, 28 Aug 2002 21:16:53 +0000 (21:16 +0000)]
Interface to Apple Help Viewer.

22 years agoQuite down some FutureWarnings.
Barry Warsaw [Wed, 28 Aug 2002 16:36:11 +0000 (16:36 +0000)]
Quite down some FutureWarnings.

22 years agoadd warning about exception messages
Skip Montanaro [Wed, 28 Aug 2002 01:14:57 +0000 (01:14 +0000)]
add warning about exception messages

22 years agoNote change in behavior from 1.5.2. The new argument to NameError is
Raymond Hettinger [Tue, 27 Aug 2002 23:53:23 +0000 (23:53 +0000)]
Note change in behavior from 1.5.2.  The new argument to NameError is
an error message and not just the missing name.

Closes SF Bug 599869.

22 years agoWhitespace normalization.
Barry Warsaw [Tue, 27 Aug 2002 22:38:50 +0000 (22:38 +0000)]
Whitespace normalization.

22 years agoTypo
Barry Warsaw [Tue, 27 Aug 2002 22:34:44 +0000 (22:34 +0000)]
Typo

22 years agoexecfile should call PyErr_SetFromErrnoWithFilename instead of
Peter Schneider-Kamp [Tue, 27 Aug 2002 16:58:00 +0000 (16:58 +0000)]
execfile should call PyErr_SetFromErrnoWithFilename instead of
simply PyErr_SetFromErrno

This closes bug 599163.

22 years agoAdd strong security warning about the rexec module.
Fred Drake [Tue, 27 Aug 2002 16:46:06 +0000 (16:46 +0000)]
Add strong security warning about the rexec module.
Closes SF patch #600861.

Minor markup changes.

22 years agoDon't use tempfile.mktemp(), since it produces annoying warnings, and
Fred Drake [Tue, 27 Aug 2002 16:34:54 +0000 (16:34 +0000)]
Don't use tempfile.mktemp(), since it produces annoying warnings, and
usually isn't what we want anyway.

22 years agoFix a couple of whitespace consistency nits.
Fred Drake [Mon, 26 Aug 2002 21:20:30 +0000 (21:20 +0000)]
Fix a couple of whitespace consistency nits.

22 years agoSimplify, and avoid PyModule_GetDict() while we're at it.
Fred Drake [Mon, 26 Aug 2002 21:15:11 +0000 (21:15 +0000)]
Simplify, and avoid PyModule_GetDict() while we're at it.

22 years agoFix an inaccuracy in the comment
Barry Warsaw [Mon, 26 Aug 2002 16:44:56 +0000 (16:44 +0000)]
Fix an inaccuracy in the comment

22 years agoGave intersection_update a speed boost.
Tim Peters [Mon, 26 Aug 2002 00:44:07 +0000 (00:44 +0000)]
Gave intersection_update a speed boost.

22 years agoGave issubet() and issuperset() major speed boosts. That's it for now!
Tim Peters [Sun, 25 Aug 2002 20:12:19 +0000 (20:12 +0000)]
Gave issubet() and issuperset() major speed boosts.  That's it for now!
Someone else may want to tackle the mutating operations similarly.

22 years agoGave __sub__/difference a factor of 2-5 speed boost.
Tim Peters [Sun, 25 Aug 2002 19:50:43 +0000 (19:50 +0000)]
Gave __sub__/difference a factor of 2-5 speed boost.

22 years agoGave __xor__/symmetric_difference a factor of 2-5 speed boost.
Tim Peters [Sun, 25 Aug 2002 19:47:54 +0000 (19:47 +0000)]
Gave __xor__/symmetric_difference a factor of 2-5 speed boost.

22 years agoSped union by a factor of 3-4.
Tim Peters [Sun, 25 Aug 2002 19:21:27 +0000 (19:21 +0000)]
Sped union by a factor of 3-4.

22 years agoSped intersection by large factors (3-5x faster than before on sets of
Tim Peters [Sun, 25 Aug 2002 19:12:45 +0000 (19:12 +0000)]
Sped intersection by large factors (3-5x faster than before on sets of
cardinality 500; and the smaller the intersection, the bigger the speedup).

22 years agoAdded a clue about why xyz_update isn't the same as __xyz__.
Tim Peters [Sun, 25 Aug 2002 18:59:04 +0000 (18:59 +0000)]
Added a clue about why xyz_update isn't the same as __xyz__.

22 years agoImplemented <, <=, >, >= for sets, giving subset and proper-subset
Tim Peters [Sun, 25 Aug 2002 18:43:10 +0000 (18:43 +0000)]
Implemented <, <=, >, >= for sets, giving subset and proper-subset
meanings.  I did not add new, e.g., ispropersubset() methods; we're
going nuts on those, and, e.g., there was no "friendly name" for
== either.

22 years agoTestSubset(): Generalized the framework to support testing upcoming
Tim Peters [Sun, 25 Aug 2002 18:21:47 +0000 (18:21 +0000)]
TestSubset():  Generalized the framework to support testing upcoming
<, <=, etc methods too.

22 years agoRewrote all remaining assert stmts.
Tim Peters [Sun, 25 Aug 2002 18:02:29 +0000 (18:02 +0000)]
Rewrote all remaining assert stmts.

22 years agoSimplified construction of the test suite.
Tim Peters [Sun, 25 Aug 2002 17:49:04 +0000 (17:49 +0000)]
Simplified construction of the test suite.

22 years agoSimplified code building sets of characters.
Tim Peters [Sun, 25 Aug 2002 17:40:29 +0000 (17:40 +0000)]
Simplified code building sets of characters.

22 years agoAck! Virtually every test here relied on an assert stmt. assert stmts
Tim Peters [Sun, 25 Aug 2002 17:38:49 +0000 (17:38 +0000)]
Ack!  Virtually every test here relied on an assert stmt.  assert stmts
should never be used in tests.  Repaired dozens, but more is needed.

22 years agoSimplified the setup for is-subset testing.
Tim Peters [Sun, 25 Aug 2002 17:22:23 +0000 (17:22 +0000)]
Simplified the setup for is-subset testing.

22 years agoRecord a clue about why __or__ is not union, etc.
Tim Peters [Sun, 25 Aug 2002 17:10:17 +0000 (17:10 +0000)]
Record a clue about why __or__ is not union, etc.

22 years agoReplace 0 with False to match working in documentation. SF 599681.
Raymond Hettinger [Sun, 25 Aug 2002 16:36:49 +0000 (16:36 +0000)]
Replace 0 with False to match working in documentation.  SF 599681.

22 years agoCorrect documentation of allow_reuse_address to match the actual script.
Raymond Hettinger [Sun, 25 Aug 2002 16:27:33 +0000 (16:27 +0000)]
Correct documentation of allow_reuse_address to match the actual script.

Closes SF bug 599681.

22 years ago1. Revert subprocess environment clearing, will restart subprocess
Kurt B. Kaiser [Sun, 25 Aug 2002 14:08:07 +0000 (14:08 +0000)]
1. Revert subprocess environment clearing, will restart subprocess
   instead.
2. Preserve the Idle client's listening socket for reuse with the
   fresh subprocess.
3. Remove some unused rpc code, comment out additional unused code.

Modified Files:
ScriptBinding.py rpc.py run.py

22 years agoImprove exception handling across rpc interface
Kurt B. Kaiser [Sat, 24 Aug 2002 23:57:17 +0000 (23:57 +0000)]
Improve exception handling across rpc interface
Modified Files:
  rpc.py

22 years agoRemoved < <= > >= from the API. Implemented as comparisons of the
Raymond Hettinger [Sat, 24 Aug 2002 07:33:06 +0000 (07:33 +0000)]
Removed < <= > >= from the API.  Implemented as comparisons of the
underlying dictionaries, there were no reasonable use cases (lexicographic
sorting of a list of sets is somewhat esoteric).  Frees the operators
for other uses (such as strict subset and superset comparisons).

Updated documentation and test suite accordingly.

22 years agostring_contains(): speed up by avoiding function calls where
Guido van Rossum [Sat, 24 Aug 2002 06:57:49 +0000 (06:57 +0000)]
string_contains(): speed up by avoiding function calls where
possible.  This always called PyUnicode_Check() and PyString_Check(),
at least one of which would call PyType_IsSubtype().  Also, this would
call PyString_Size() on known string objects.

22 years agoSpeed up the most egregious "if token in (long tuple)" cases by using
Guido van Rossum [Sat, 24 Aug 2002 06:54:19 +0000 (06:54 +0000)]
Speed up the most egregious "if token in (long tuple)" cases by using
a dict instead.  (Alas, using a Set would be slower instead of
faster.)

22 years agoSpeedup for PyObject_IsTrue(): check for True and False first.
Guido van Rossum [Sat, 24 Aug 2002 06:31:34 +0000 (06:31 +0000)]
Speedup for PyObject_IsTrue(): check for True and False first.
Because all built-in tests return bools now, this is the most common
path!

22 years agoAt Tim Peter's suggestion, propagated GvR's binary operator changes to
Raymond Hettinger [Sat, 24 Aug 2002 06:19:02 +0000 (06:19 +0000)]
At Tim Peter's suggestion, propagated GvR's binary operator changes to
the inplace operators.  The strategy is to have the operator overloading
code do the work and then to define equivalent method calls which rely on
the operators.  The changes facilitate proper application of TypeError
and NonImplementedErrors.

Added corresponding tests to the test suite to make sure both the operator
and method call versions get exercised.

Add missing tests for difference_update().

22 years agoSpeedup for PyObject_RichCompareBool(): PyObject_RichCompare() almost
Guido van Rossum [Sat, 24 Aug 2002 05:33:28 +0000 (05:33 +0000)]
Speedup for PyObject_RichCompareBool(): PyObject_RichCompare() almost
always returns a bool, so avoid calling PyObject_IsTrue() in that
case.

22 years agoSince instances of _TemporarilyImmutableSet are always thrown away
Raymond Hettinger [Sat, 24 Aug 2002 04:47:42 +0000 (04:47 +0000)]
Since instances of _TemporarilyImmutableSet are always thrown away
immediately after the comparison, there in no use in caching the hashcode.
The test, 'if self._hashcode is None', never fails.  Removing the caching
saves a few lines and a little time.

22 years agoExpanded tests for sets of sets.
Raymond Hettinger [Sat, 24 Aug 2002 02:56:01 +0000 (02:56 +0000)]
Expanded tests for sets of sets.

22 years ago1. Removed module self test in favor of unittests -- Timbot's suggestion.
Raymond Hettinger [Sat, 24 Aug 2002 02:35:48 +0000 (02:35 +0000)]
1. Removed module self test in favor of unittests -- Timbot's suggestion.
2. Replaced calls to Set([]) with Set() -- Timbot's suggestion
3. Fixed subtle bug in sets of sets:

The following code did not work (will add to test suite):
    d = Set('d')
    s = Set([d])  # Stores inner set as an ImmutableSet
    s.remove(d)   # For comparison, wraps d in _TemporarilyImmutableSet

The comparison proceeds by computing the hash of the
_TemporarilyImmutableSet and finding it in the dictionary.
It then verifies equality by calling ImmutableSet.__eq__()
and crashes from the binary sanity check.

The problem is that the code assumed equality would be checked
with _TemporarilyImmutableSet.__eq__().

The solution is to let _TemporarilyImmutableSet derive from BaseSet
so it will pass the sanity check and then to provide it with the
._data element from the wrapped set so that ImmutableSet.__eq__()
will find ._data where it expects.

Since ._data is now provided and because BaseSet is the base class,
_TemporarilyImmutableSet no longer needs .__eq__() or .__ne__().

Note that inheriting all of BaseSet's methods is harmless because
none of those methods (except ones starting with an underscore)
can mutate the .data element.  Also _TemporarilyImmutableSet is only
used internally as is not otherwise visible.

22 years agoFix typo reported to python-docs.
Fred Drake [Fri, 23 Aug 2002 21:19:53 +0000 (21:19 +0000)]
Fix typo reported to python-docs.

22 years agopop() docstring: this isn't a randomly-chosen element, it's merely
Tim Peters [Fri, 23 Aug 2002 20:36:58 +0000 (20:36 +0000)]
pop() docstring:  this isn't a randomly-chosen element, it's merely
arbitrary.  I already changed the docs for this.

22 years agoComment repair.
Tim Peters [Fri, 23 Aug 2002 20:06:42 +0000 (20:06 +0000)]
Comment repair.

22 years agoFix SF bug 599128, submitted by Inyeol Lee: .replace() would do the
Guido van Rossum [Fri, 23 Aug 2002 18:50:21 +0000 (18:50 +0000)]
Fix SF bug 599128, submitted by Inyeol Lee: .replace() would do the
wrong thing for a unicode subclass when there were zero string
replacements.  The example given in the SF bug report was only one way
to trigger this; replacing a string of length >= 2 that's not found is
another.  The code would actually write outside allocated memory if
replacement string was longer than the search string.

(I wonder how many more of these are lurking?  The unicode code base
is full of wonders.)

Bugfix candidate; this same bug is present in 2.2.1.

22 years agoCode by Inyeol Lee, submitted to SF bug 595350, to implement
Guido van Rossum [Fri, 23 Aug 2002 18:21:28 +0000 (18:21 +0000)]
Code by Inyeol Lee, submitted to SF bug 595350, to implement
the string/unicode method .replace() with a zero-lengt first argument.
Inyeol contributed tests for this too.

22 years agoWhitespace normalization.
Tim Peters [Fri, 23 Aug 2002 18:19:30 +0000 (18:19 +0000)]
Whitespace normalization.

22 years agoFix markup and punctuation
Raymond Hettinger [Fri, 23 Aug 2002 18:10:54 +0000 (18:10 +0000)]
Fix markup and punctuation

22 years agoGot rid of the toy _Set class, in favor of sets.Set.
Tim Peters [Fri, 23 Aug 2002 17:55:54 +0000 (17:55 +0000)]
Got rid of the toy _Set class, in favor of sets.Set.

22 years agos/_as_Temporarily_Immutable/_as_temporarily_immutable/g, because the
Tim Peters [Fri, 23 Aug 2002 17:48:23 +0000 (17:48 +0000)]
s/_as_Temporarily_Immutable/_as_temporarily_immutable/g, because the
latter is what the code actually does.

22 years agopop(): An arbitrary element is removed, not a random element.
Tim Peters [Fri, 23 Aug 2002 17:45:43 +0000 (17:45 +0000)]
pop():  An arbitrary element is removed, not a random element.

22 years agoAdjust the markup in a few places so this will actually format.
Fred Drake [Fri, 23 Aug 2002 17:22:36 +0000 (17:22 +0000)]
Adjust the markup in a few places so this will actually format.
Remove the third column in the tables since it isn't used.

22 years agoAdd an entry for the sets module documentation.
Fred Drake [Fri, 23 Aug 2002 15:38:02 +0000 (15:38 +0000)]
Add an entry for the sets module documentation.
Move another entry so the boilerplate doesn't get mixed up with
document-specific content.

22 years agoLoad docs for sets.py
Raymond Hettinger [Fri, 23 Aug 2002 15:18:38 +0000 (15:18 +0000)]
Load docs for sets.py

22 years agoRH pointed out that discard(element) doesn't do the transformation on
Guido van Rossum [Fri, 23 Aug 2002 14:45:02 +0000 (14:45 +0000)]
RH pointed out that discard(element) doesn't do the transformation on
the element if necessary.  Fixed by calling self.remove(element).