summaryrefslogtreecommitdiffstats
path: root/Lib
Commit message (Collapse)AuthorAgeFilesLines
* On Windows, make sure SocketType is the same as socket. (SF bugGuido van Rossum2002-08-221-1/+1
| | | | 598097)
* Change the binary operators |, &, ^, - to return NotImplemented ratherGuido van Rossum2002-08-221-14/+40
| | | | | | | | | | | | | | | | | | | | 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.
* Added a main() function and support to run this module as a script.Fred Drake2002-08-211-1/+19
| | | | Closes SF feature request #588768.
* Refactor: Remove some code that was obsoleted when this module wasFred Drake2002-08-211-11/+17
| | | | | | | | | 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.
* Now that __init__ transforms set elements, we know that all of theRaymond Hettinger2002-08-211-1/+3
| | | | | elements are hashable, so we can use dict.update() or dict.copy() for a C speed Set.copy().
* Add regression test for proper construction of sets of sets.Raymond Hettinger2002-08-211-0/+10
|
* Sped ._update() method by factoring try/except out of the inner loop.Raymond Hettinger2002-08-211-4/+5
|
* Ouch. The test suite *really* needs work!!!!! There were severalGuido van Rossum2002-08-211-46/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Add Raymond H to the list of authors; add some XXX comments aboutGuido van Rossum2002-08-211-0/+9
| | | | possible API improvements.
* Fast size check for sub/super set testsRaymond Hettinger2002-08-211-0/+4
|
* Optimize try/except ordering in sets.py.Raymond Hettinger2002-08-211-25/+25
| | | | | | | | 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.
* Minor typoRaymond Hettinger2002-08-201-1/+1
|
* Rename popitem() to pop(). (An idea from SF patch 597444.)Guido van Rossum2002-08-202-3/+3
|
* Move __init__ from BaseSet into Set and ImmutableSet. This causes aGuido van Rossum2002-08-201-16/+28
| | | | | tiny amount of code duplication, but makes it possible to give BaseSet an __init__ that raises an exception.
* Typo repair. Please include in any backports.Guido van Rossum2002-08-201-1/+1
|
* Add a note reminding the reader that sets are not sequences. IGuido van Rossum2002-08-201-0/+10
| | | | | received feedback that was based in the misunderstanding that sets were sequences.
* SF patch 595846 by Brett Cannon: Update environ for CGIHTTPServer.pyGuido van Rossum2002-08-201-2/+1
| | | | | | | This patch causes CGIHTTPServer to update os.environ regardless of how it tries to handle calls (fork, popen*, etc.). Backport bugfix candidate.
* Fix some endcase bugs in unicode rfind()/rindex() and endswith().Guido van Rossum2002-08-201-0/+6
| | | | | | These were reported and fixed by Inyeol Lee in SF bug 595350. The endswith() bug was already fixed in 2.3, but this adds some more test cases.
* Bump version number to 2.3Barry Warsaw2002-08-201-1/+1
|
* Added tests for SF patch #597593, syntactically invalid Content-Type: headers.Barry Warsaw2002-08-201-2/+23
|
* get_content_type(), get_content_maintype(), get_content_subtype(): RFCBarry Warsaw2002-08-201-5/+5
| | | | | | | | | | | 2045, section 5.2 states that if the Content-Type: header is syntactically invalid, the default type should be text/plain. Implement minimal sanity checking of the header -- it must have exactly one slash in it. This closes SF patch #597593 by Skip, but in a different way. Note that these methods used to raise ValueError for invalid ctypes, but now they won't.
* _dispatch(): Use get_content_maintype() and get_content_subtype() toBarry Warsaw2002-08-201-3/+2
| | | | | | get the MIME main and sub types, instead of getting the whole ctype and splitting it here. The two more specific methods now correctly implement RFC 2045, section 5.2.
* test_three_lines(): Test case reported by Andrew McNamara. Works inBarry Warsaw2002-08-201-0/+8
| | | | email 2.2 but fails in email 1.0.
* Fix typo in __slots__ of ImmutableSet.Guido van Rossum2002-08-191-1/+1
|
* Set classes and their unit tests, from sandbox.Guido van Rossum2002-08-192-0/+1097
|
* Added __pow__(a,b) to the operator module. Completes the pattern ofRaymond Hettinger2002-08-191-0/+6
| | | | | | all operators having a counterpart in the operator module. Closes SF bug #577513.
* Modify splituser() method to allow an @ in the userinfo field.Raymond Hettinger2002-08-181-1/+1
| | | | | | | Jeremy reported that this is not allowed by RFC 2396; however, other tools support unescaped @'s so we should also. Apply SF patch 596581 closing bug 581529.
* OS/2 EMX behaves like Windows where file permissions are concernedAndrew MacIntyre2002-08-181-2/+2
|
* Get rid of _once(); inlining it takes less code. :-)Guido van Rossum2002-08-172-97/+41
| | | | | | | Also, don't call gettempdir() in the default expression for the 'dir' argument to various functions; use 'dir=None' for the default and insert 'if dir is None: dir = gettemptir()' in the bodies. That way the work done by gettempdir is postponed until needed.
* Patch by Zack W to make test_noinherit() more robust: spawn a PythonGuido van Rossum2002-08-172-28/+48
| | | | | subprocess that does the right checks. This now works on Windows as well.
* Drop the number of test files to 100 for all the testsNeal Norwitz2002-08-161-4/+8
|
* SF bug 594996: OverflowError in random.randrangeTim Peters2002-08-161-4/+17
| | | | | | Loosened the acceptable 'start' and 'stop' arguments so that any Python (bounded) ints can be used. So, e.g., randrange(-sys.maxint-1, sys.maxint) no longer blows up.
* check_events(): This was failing under -O, due to not expecting anyTim Peters2002-08-161-3/+0
| | | | | LINE events when not __debug__. But we get them anyway under -O now, so just stop special-casing non-__debug__ mode.
* base64.decodestring('') should return '' instead of raising anBarry Warsaw2002-08-151-6/+1
| | | | | exception. The bug fix for SF #430849 wasn't quite right. This closes SF bug #595671. I'll backport this to Python 2.2.
* This is my patchMichael W. Hudson2002-08-155-42/+47
| | | | | | | | [ 587993 ] SET_LINENO killer Remove SET_LINENO. Tracing is now supported by inspecting co_lnotab. Many sundry changes to document and adapt to this change.
* forgot the best part - the new tests...Skip Montanaro2002-08-151-0/+32
| | | | see patch 586561
* Docstring nits: The module is neither proposed nor new.Jeremy Hylton2002-08-141-1/+1
|
* More changes of DeprecationWarning to FutureWarning.Guido van Rossum2002-08-142-2/+2
|
* Explain use of currentThread() in _Condition methods.Jeremy Hylton2002-08-141-2/+2
|
* The filterwarnings() call here should be updated to filter outGuido van Rossum2002-08-141-1/+1
| | | | FutureWarning.
* Explain a little more.Jeremy Hylton2002-08-141-0/+1
|
* Explain a minor mystery.Jeremy Hylton2002-08-141-0/+1
|
* tempfile's mkstemp(): Changed last argument fromTim Peters2002-08-142-11/+11
| | | | | | | | | | binary=True to text=False by BDFL Pronouncement. All other changes follow from this. The change to the docs is ready to go, but blocked by another JackMacLock in the doc directory.
* Patch #595014: Cygwin tempfile patchJason Tishler2002-08-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Although Cygwin attempts to be as Posix compliant as possible, it has difficulties unlinking open files. This is not surprising given that Cygwin is dependent on Win32 which in turn has this problem itself. The attached tempfile patch acknowledges this Cygwin limitation. Without this patch, Cygwin fails test_tempfile (i.e., test_has_no_name) as follows: $ ./python -E -tt ../Lib/test/regrtest.py -l test_tempfile test_tempfile test test_tempfile failed -- Traceback (most recent call last): File "/home/jt/src/PythonCvs/Lib/test/test_tempfile.py", line 689, in test_has_no_name self.failOnException("rmdir", ei) File "/home/jt/src/PythonCvs/Lib/test/test_tempfile.py", line 33, in failOnException self.fail("%s raised %s: %s" % (what, ei[0], ei[1])) File "/home/jt/src/PythonCvs/Lib/unittest.py", line 260, in fail raise self.failureException, msg AssertionError: rmdir raised exceptions.OSError: [Errno 90] Directory not empty: '/mnt/c/DOCUME~1/jatis/LOCALS~1/Temp/tmpM_z8nj'
* Patch by Tim to shut up the compiler's DeprecationWarnings on theBarry Warsaw2002-08-141-18/+9
| | | | high-bit-set hex constants.
* test_many(): open only 100 temp files, not 1000. Some systems don'tGuido van Rossum2002-08-141-1/+1
| | | | | allow that many open files per process. I don't see that 1000 makes any difference for the test.
* Check for trailing backslash. Fixes #593656.Martin v. Löwis2002-08-141-0/+1
|
* Patch #505705: Remove eval in pickle and cPickle.Martin v. Löwis2002-08-143-6/+36
|
* tightening up a few except: clausesSkip Montanaro2002-08-141-3/+3
| | | | see bug 411881
* runtest(): I don't know why we don't just use TESTFN, but if we have toTim Peters2002-08-141-4/+5
| | | | | | | | | | | | | do bizarre things to get a temp file, I changed it to use mkstemp instead of NamedTemporaryFile. This tried to leave the file open while passing its name to execfile(). On Win2K (but not Win9X), though, a file created with O_TEMPORARY cannot be opened again, so the test failed with a permission error when execfile tried to open it. Closer to the truth: a file created with O_TEMPORARY can be opened again, but only if the file is also created with SHARE_DELETE access via the Win32 CreateFile() function. There's no way to get at that from MS's version of libc, though (we'd have to ditch the "std" C file functions in favor of Win32 API calls).