]> granicus.if.org Git - python/log
python
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).

22 years agoThe error messages in err_args() -- which is only called when the
Guido van Rossum [Fri, 23 Aug 2002 14:11:35 +0000 (14:11 +0000)]
The error messages in err_args() -- which is only called when the
required number of args is 0 or 1 -- were reversed.  Also change "1"
into "exactly one", the same words as used elsewhere for this
condition.

22 years agoAdded the standard MacOSX location for documentation inside a framework
Jack Jansen [Fri, 23 Aug 2002 08:40:42 +0000 (08:40 +0000)]
Added the standard MacOSX location for documentation inside a framework
to the list of places where pydoc looks for HTML documents.

22 years agoRewritten using the tokenize module, which gives us a real tokenizer
Guido van Rossum [Fri, 23 Aug 2002 01:36:01 +0000 (01:36 +0000)]
Rewritten using the tokenize module, which gives us a real tokenizer
rather than a number of approximating regular expressions.
Alas, it is 3-4 times slower.  Let that be a challenge for the
tokenize module.

22 years agoDon't build ConfigurePythonCarbon and ConfigurePythonClassic any longer,
Jack Jansen [Thu, 22 Aug 2002 23:37:00 +0000 (23:37 +0000)]
Don't build ConfigurePythonCarbon and ConfigurePythonClassic any longer,
classic Python is gone.

22 years agoFor MacPython-OS9 verbose is the default.
Jack Jansen [Thu, 22 Aug 2002 23:36:11 +0000 (23:36 +0000)]
For MacPython-OS9 verbose is the default.

22 years agoInterface to Apple Help Manager.
Jack Jansen [Thu, 22 Aug 2002 23:31:37 +0000 (23:31 +0000)]
Interface to Apple Help Manager.

22 years agoMoved CoreFoundation type support to bgen/macsupport.
Jack Jansen [Thu, 22 Aug 2002 23:30:49 +0000 (23:30 +0000)]
Moved CoreFoundation type support to bgen/macsupport.

22 years agoAdded PyDoc_STR's.
Jack Jansen [Thu, 22 Aug 2002 23:29:45 +0000 (23:29 +0000)]
Added PyDoc_STR's.

22 years agoTweak wordsep_re again: this time to recognize an em-dash with
Greg Ward [Thu, 22 Aug 2002 21:28:00 +0000 (21:28 +0000)]
Tweak wordsep_re again: this time to recognize an em-dash with
any non-whitespace characters adjacent, not just \w.

22 years agoTest an em-dash with adjacent punctuation.
Greg Ward [Thu, 22 Aug 2002 21:27:05 +0000 (21:27 +0000)]
Test an em-dash with adjacent punctuation.

22 years agoFactored out BaseTestCase.check_split() method -- use it wherever
Greg Ward [Thu, 22 Aug 2002 21:16:25 +0000 (21:16 +0000)]
Factored out BaseTestCase.check_split() method -- use it wherever
we need to test TextWrapper._split().

22 years agoTest _split() method in test_unix_options().
Greg Ward [Thu, 22 Aug 2002 21:12:54 +0000 (21:12 +0000)]
Test _split() method in test_unix_options().

22 years agoAdd test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward [Thu, 22 Aug 2002 21:10:07 +0000 (21:10 +0000)]
Add test_unix_options() to WrapTestCase to test for SF bug #596434.

22 years agoFix SF bug #596434: tweak wordsep_re so "--foo-bar" now splits
Greg Ward [Thu, 22 Aug 2002 21:04:21 +0000 (21:04 +0000)]
Fix SF bug #596434: tweak wordsep_re so "--foo-bar" now splits
into /--foo-/bar/ rather than /--/foo-/bar/.  Needed for Optik and
Docutils to handle Unix-style command-line options properly.

22 years agoStandardize behavior: no docstrings in test functions.
Guido van Rossum [Thu, 22 Aug 2002 20:22:16 +0000 (20:22 +0000)]
Standardize behavior: no docstrings in test functions.

22 years agoStandardize behavior: no docstrings in test functions. Also use
Guido van Rossum [Thu, 22 Aug 2002 20:21:30 +0000 (20:21 +0000)]
Standardize behavior: no docstrings in test functions.  Also use
unittest.makeSuite() rather than loader.loadTestsFromTestCase().

22 years agoStandardize behavior: no docstrings in test functions. Also strip
Guido van Rossum [Thu, 22 Aug 2002 20:13:47 +0000 (20:13 +0000)]
Standardize behavior: no docstrings in test functions.  Also strip
trailing whitespace.

22 years agoDocument that docstrings are verboten for test functions.
Guido van Rossum [Thu, 22 Aug 2002 20:08:14 +0000 (20:08 +0000)]
Document that docstrings are verboten for test functions.

Expand the example to show some actual test functions, and a setUp()
and tearDown() method.

22 years agoStandardize behavior: no docstrings in test functions. Also get rid
Guido van Rossum [Thu, 22 Aug 2002 20:02:03 +0000 (20:02 +0000)]
Standardize behavior: no docstrings in test functions.  Also get rid
of dummy_test_TemporaryFile class; when NamedTemporaryFile and
TemporaryFile are the same, simply don't add a test suite for
TemporaryFile.

22 years agoStandardize behavior: no docstrings in test functions; add a proper
Guido van Rossum [Thu, 22 Aug 2002 19:57:50 +0000 (19:57 +0000)]
Standardize behavior: no docstrings in test functions; add a proper
test_main() that creates a suite and runs it.  Don't mess with sys.path!!!

22 years agoAdd test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward [Thu, 22 Aug 2002 19:47:27 +0000 (19:47 +0000)]
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
em-dashes -- like this -- properly.  (Also--like this.  Although this
usage may be incompatible with fixing bug #596434; we shall see.)

22 years agoStandardize behavior: no docstrings in test functions.
Guido van Rossum [Thu, 22 Aug 2002 19:45:32 +0000 (19:45 +0000)]
Standardize behavior: no docstrings in test functions.

22 years agoStandardize behavior: create a single suite merging all test cases.
Guido van Rossum [Thu, 22 Aug 2002 19:40:33 +0000 (19:40 +0000)]
Standardize behavior: create a single suite merging all test cases.

22 years agoStandardize behavior: no docstrings in test functions; create a single
Guido van Rossum [Thu, 22 Aug 2002 19:38:14 +0000 (19:38 +0000)]
Standardize behavior: no docstrings in test functions; create a single
suite merging all test cases.

22 years agoMade it more readable.
Guido van Rossum [Thu, 22 Aug 2002 19:18:56 +0000 (19:18 +0000)]
Made it more readable.

22 years agoFix peculiar (and ungrammatical) wording in an example program.
Greg Ward [Thu, 22 Aug 2002 19:15:35 +0000 (19:15 +0000)]
Fix peculiar (and ungrammatical) wording in an example program.

22 years agoSimplification/cleanup in IndentTestCases.
Greg Ward [Thu, 22 Aug 2002 19:06:45 +0000 (19:06 +0000)]
Simplification/cleanup in IndentTestCases.

22 years agoFactor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward [Thu, 22 Aug 2002 19:02:37 +0000 (19:02 +0000)]
Factor LongWordTestCase out of WrapTestCase, and rename its methods
(tests) from test_funky_punc() to test_break_long() and
test_long_words() to test_nobreak_long().

22 years agoRename base test case class to (yawn) BaseTestCase.
Greg Ward [Thu, 22 Aug 2002 18:57:26 +0000 (18:57 +0000)]
Rename base test case class to (yawn) BaseTestCase.

22 years agoDitch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward [Thu, 22 Aug 2002 18:55:38 +0000 (18:55 +0000)]
Ditch the whole loop-over-subcases way of working.  Add check_wrap() to
base class (WrapperTestCase) instead, and call it repeatedly in the
methods that used to have a loop-over-subcases.  Much simpler.

Rename perennial temp variable 't' to 'text'.

22 years agoSimplify and reformat the use of 'subcases' lists (and following
Greg Ward [Thu, 22 Aug 2002 18:45:02 +0000 (18:45 +0000)]
Simplify and reformat the use of 'subcases' lists (and following
for-loops) in test_simple(), test_wrap_short() test_hyphenated(), and
test_funky_punc().

22 years agoAdd comment header block.
Greg Ward [Thu, 22 Aug 2002 18:37:50 +0000 (18:37 +0000)]
Add comment header block.
Remove some useless comments (redundant, or info presumably available in
  PyUnit docs).

22 years agoConform to standards documented in README:
Greg Ward [Thu, 22 Aug 2002 18:35:49 +0000 (18:35 +0000)]
Conform to standards documented in README:
  *  lowercase test*() methods
  * define test_main() and use it instead of unittest.main()
Kill #! line.
Improve some test names and docstrings.

22 years agoTest script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward [Thu, 22 Aug 2002 18:11:10 +0000 (18:11 +0000)]
Test script for the textwrap module.  Kindly provided by Peter Hansen
<peter@engcorp.com> based on a test script that's been kicking around my
home directory for a couple of months now and only saw the light of day
because I included it when I sent textwrap.py to python-dev for review.

22 years agoOn Windows, make sure SocketType is the same as socket. (SF bug
Guido van Rossum [Thu, 22 Aug 2002 17:31:16 +0000 (17:31 +0000)]
On Windows, make sure SocketType is the same as socket.  (SF bug
598097)

22 years agoChange the binary operators |, &, ^, - to return NotImplemented rather
Guido van Rossum [Thu, 22 Aug 2002 17:23:33 +0000 (17:23 +0000)]
Change the binary operators |, &, ^, - to return NotImplemented rather
than raising TypeError when the other argument is not a BaseSet.  This
made it necessary to separate the implementation of e.g. __or__ from
the union method; the latter should not return NotImplemented but
raise TypeError.  This is accomplished by making union(self, other)
return self|other, etc.; Python's binary operator machinery will raise
TypeError.

The idea behind this change is to allow other set implementations with
an incompatible internal structure; these can provide union (etc.) with
standard sets by implementing __ror__ etc.

I wish I could do this for comparisons too, but the default comparison
implementation allows comparing anything to anything else (returning
false); we don't want that (at least the test suite makes sure
e.g. Set()==42 raises TypeError).  That's probably fine; otherwise
other set implementations would be constrained to implementing a hash
that's compatible with ours.

22 years agoGive the section on PEP 263 a more meaningful title, so readers will
Fred Drake [Thu, 22 Aug 2002 16:51:08 +0000 (16:51 +0000)]
Give the section on PEP 263 a more meaningful title, so readers will
be able to locate this information without knowing the PEP number.

22 years agoAdd a note that apply() is needed since the extended call syntax is
Fred Drake [Thu, 22 Aug 2002 14:27:35 +0000 (14:27 +0000)]
Add a note that apply() is needed since the extended call syntax is
completely equivalent.

22 years agoFix grammatically inept comment.
Michael W. Hudson [Thu, 22 Aug 2002 13:36:11 +0000 (13:36 +0000)]
Fix grammatically inept comment.

22 years agoAdded a main() function and support to run this module as a script.
Fred Drake [Wed, 21 Aug 2002 20:56:21 +0000 (20:56 +0000)]
Added a main() function and support to run this module as a script.
Closes SF feature request #588768.

22 years agoRefactor: Remove some code that was obsoleted when this module was
Fred Drake [Wed, 21 Aug 2002 20:23:22 +0000 (20:23 +0000)]
Refactor:  Remove some code that was obsoleted when this module was
           changed to use universal newlines.

           Remove all imports from the compile() function; these are
           now done at the top of the module ("Python normal form"),
           and define a helper based on the platform instead of
           testing the platform in the compile() function.

22 years agoClarify that even though some of the relevant specifications define the
Fred Drake [Wed, 21 Aug 2002 19:24:21 +0000 (19:24 +0000)]
Clarify that even though some of the relevant specifications define the
order in which form variables should be encoded in a request, a CGI script
should not rely on that since a client may not conform to those specs, or
they may not be relevant to the request.
Closes SF bug #596866.

22 years agoNow that __init__ transforms set elements, we know that all of the
Raymond Hettinger [Wed, 21 Aug 2002 13:20:51 +0000 (13:20 +0000)]
Now that __init__ transforms set elements, we know that all of the
elements are hashable, so we can use dict.update() or dict.copy()
for a C speed Set.copy().

22 years agoAdd regression test for proper construction of sets of sets.
Raymond Hettinger [Wed, 21 Aug 2002 06:38:44 +0000 (06:38 +0000)]
Add regression test for proper construction of sets of sets.

22 years agoReplace all cases of "while 1" with "while True".
Raymond Hettinger [Wed, 21 Aug 2002 04:54:00 +0000 (04:54 +0000)]
Replace all cases of "while 1" with "while True".
Though slightly slower, has better clarity and teaching value.

22 years agoSped ._update() method by factoring try/except out of the inner loop.
Raymond Hettinger [Wed, 21 Aug 2002 04:12:03 +0000 (04:12 +0000)]
Sped ._update() method by factoring try/except out of the inner loop.

22 years agoOuch. The test suite *really* needs work!!!!! There were several
Guido van Rossum [Wed, 21 Aug 2002 03:20:44 +0000 (03:20 +0000)]
Ouch.  The test suite *really* needs work!!!!!  There were several
superficial errors and one deep one that aren't currently caught.  I'm
headed for bed after this checkin.

- Fixed several typos introduced by Raymond Hettinger (through
  cut-n-paste from my template): it's _as_temporarily_immutable, not
  _as_temporary_immutable, and moreover when the element is added, we
  should use _as_immutable.

- Made the seq argument to ImmutableSet.__init__ optional, so we can
  write ImmutableSet() to create an immutable empty set.

- Rename the seq argument to Set and ImmutableSet to iterable.

- Add a Set.__hash__ method that raises a TypeError.  We inherit a
  default __hash__ implementation from object, and we don't want that.
  We can then catch this in update(), so that
  e.g. s.update([Set([1])]) will transform the Set([1]) to
  ImmutableSet([1]).

- Added the dance to catch TypeError and try _as_immutable in the
  constructors too (by calling _update()).  This is needed so that
  Set([Set([1])]) is correctly interpreted as
  Set([ImmutableSet([1])]).  (I was puzzled by a side effect of this
  and the inherited __hash__ when comparing two sets of sets while
  testing different powerset implementations: the Set element passed
  to a Set constructor wasn't transformed to an ImmutableSet, and then
  the dictionary didn't believe the Set found in one dict it was the
  same as ImmutableSet in the other, because the hashes were
  different.)

- Refactored Set.update() and both __init__() methods; moved the body
  of update() into BaseSet as _update(), and call this from __init__()
  and update().

- Changed the NotImplementedError in BaseSet.__init__ to TypeError,
  both for consistency with basestring() and because we have to use
  TypeError when denying Set.__hash__.  Together those provide
  sufficient evidence that an unimplemented method needs to raise
  TypeError.

22 years agoAdd Raymond H to the list of authors; add some XXX comments about
Guido van Rossum [Wed, 21 Aug 2002 02:44:04 +0000 (02:44 +0000)]
Add Raymond H to the list of authors; add some XXX comments about
possible API improvements.

22 years agoFast size check for sub/super set tests
Raymond Hettinger [Wed, 21 Aug 2002 02:22:08 +0000 (02:22 +0000)]
Fast size check for sub/super set tests

22 years agoOptimize try/except ordering in sets.py.
Raymond Hettinger [Wed, 21 Aug 2002 01:35:29 +0000 (01:35 +0000)]
Optimize try/except ordering in sets.py.

Gains a 5:1 speed-up for membership testing by
handling the most common case first (the case
where the element is hashable).

Closes SF Patch 597444.

22 years agoMinor typo
Raymond Hettinger [Tue, 20 Aug 2002 23:34:01 +0000 (23:34 +0000)]
Minor typo

22 years agoRename popitem() to pop(). (An idea from SF patch 597444.)
Guido van Rossum [Tue, 20 Aug 2002 21:51:59 +0000 (21:51 +0000)]
Rename popitem() to pop().  (An idea from SF patch 597444.)

22 years agoMove __init__ from BaseSet into Set and ImmutableSet. This causes a
Guido van Rossum [Tue, 20 Aug 2002 21:38:37 +0000 (21:38 +0000)]
Move __init__ from BaseSet into Set and ImmutableSet.  This causes a
tiny amount of code duplication, but makes it possible to give BaseSet
an __init__ that raises an exception.

22 years agoTypo repair. Please include in any backports.
Guido van Rossum [Tue, 20 Aug 2002 20:07:10 +0000 (20:07 +0000)]
Typo repair.  Please include in any backports.

22 years agoAdd a note reminding the reader that sets are not sequences. I
Guido van Rossum [Tue, 20 Aug 2002 20:05:23 +0000 (20:05 +0000)]
Add a note reminding the reader that sets are not sequences.  I
received feedback that was based in the misunderstanding that sets
were sequences.

22 years agoSF patch 595846 by Brett Cannon: Update environ for CGIHTTPServer.py
Guido van Rossum [Tue, 20 Aug 2002 19:55:06 +0000 (19:55 +0000)]
SF patch 595846 by Brett Cannon: Update environ for CGIHTTPServer.py

This patch causes CGIHTTPServer to update os.environ regardless of how
it tries to handle calls (fork, popen*, etc.).

Backport bugfix candidate.