Commit Graph

4518 Commits

Author SHA1 Message Date
Fred Drake 992d387540 Convert a couple of comments to docstrings -- PyUnit can use these when
the regression test is run in verbose mode.
2001-05-14 19:15:23 +00:00
Tim Peters 95b3f78622 pprint's workhorse _safe_repr() function took time quadratic in the # of
elements when crunching a list, dict or tuple.  Now takes linear time
instead -- huge speedup for even moderately large containers, and the
code is notably simpler too.
Added some basic "is the output correct?" tests to test_pprint.
2001-05-14 18:39:41 +00:00
Fred Drake 43913dd27c Convert the pprint test to use PyUnit. 2001-05-14 17:41:20 +00:00
Tim Peters a814db579d SF bug[ #423781: pprint.isrecursive() broken. 2001-05-14 07:05:58 +00:00
Tim Peters a0599575aa A disgusting "fix" for the test___all__ failure under Windows. 2001-05-13 09:01:06 +00:00
Mark Hammond ef8b654bbe Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465. 2001-05-13 08:04:26 +00:00
Tim Peters 2f228e75e4 Get rid of the superstitious "~" in dict hashing's "i = (~hash) & mask".
The comment following used to say:
	/* We use ~hash instead of hash, as degenerate hash functions, such
	   as for ints <sigh>, can have lots of leading zeros. It's not
	   really a performance risk, but better safe than sorry.
	   12-Dec-00 tim:  so ~hash produces lots of leading ones instead --
	   what's the gain? */
That is, there was never a good reason for doing it.  And to the contrary,
as explained on Python-Dev last December, it tended to make the *sum*
(i + incr) & mask (which is the first table index examined in case of
collison) the same "too often" across distinct hashes.

Changing to the simpler "i = hash & mask" reduced the number of string-dict
collisions (== # number of times we go around the lookup for-loop) from about
6 million to 5 million during a full run of the test suite (these are
approximate because the test suite does some random stuff from run to run).
The number of collisions in non-string dicts also decreased, but not as
dramatically.

Note that this may, for a given dict, change the order (wrt previous
releases) of entries exposed by .keys(), .values() and .items().  A number
of std tests suffered bogus failures as a result.  For dicts keyed by
small ints, or (less so) by characters, the order is much more likely to be
in increasing order of key now; e.g.,

>>> d = {}
>>> for i in range(10):
...    d[i] = i
...
>>> d
{0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9}
>>>

Unfortunately. people may latch on to that in small examples and draw a
bogus conclusion.

test_support.py
    Moved test_extcall's sortdict() into test_support, made it stronger,
    and imported sortdict into other std tests that needed it.
test_unicode.py
    Excluced cp875 from the "roundtrip over range(128)" test, because
    cp875 doesn't have a well-defined inverse for unicode("?", "cp875").
    See Python-Dev for excruciating details.
Cookie.py
    Chaged various output functions to sort dicts before building
    strings from them.
test_extcall
    Fiddled the expected-result file.  This remains sensitive to native
    dict ordering, because, e.g., if there are multiple errors in a
    keyword-arg dict (and test_extcall sets up many cases like that), the
    specific error Python complains about first depends on native dict
    ordering.
2001-05-13 00:19:31 +00:00
Fred Drake 7e473800c3 Fix one bare except: clause. 2001-05-11 19:52:57 +00:00
Fred Drake 6f6a14f888 Remove a bare try/except completely -- it just did not make sense!
Add a comment elsewhere making clear an assumption in the code.
2001-05-11 19:25:08 +00:00
Fred Drake e8187615e2 When guarding an import, only catch ImportError. 2001-05-11 19:21:41 +00:00
Fred Drake 31e18291c5 Clean up a bare except where we only expect to catch pcre.error. 2001-05-11 19:20:17 +00:00
Fred Drake 652553192e Clean up bare except where only IOError makes sense. 2001-05-11 19:15:28 +00:00
Fred Drake 553f68114f Clean up bare except: when determining whether a file is seekable. 2001-05-11 19:14:51 +00:00
Fred Drake 776d39e2c7 Opening a file for reading can raise IOError, so only catch that. 2001-05-11 18:47:54 +00:00
Fred Drake 1b7e079528 int() of a string is only expected to through ValueError, so do not use
a bare except clause.
2001-05-11 18:45:52 +00:00
Fred Drake 9f9b593f8d <socket>.getsockopt() and <socket>.setsockopt() can only raise socket.error,
so only catch that specific exception.
2001-05-11 18:28:54 +00:00
Fred Drake c79f3d0d42 Catch only the relevant exceptions instead of using a bare except clause. 2001-05-11 18:27:00 +00:00
Fred Drake 6278799f8e unlink() would normally be found in the "os" module, so use it from there.
Remove unused import of "sys".

If the file TESTFN exists before we start, try to remove it.

Add spaces around the = in some assignments.
2001-05-11 14:29:21 +00:00
Tim Peters 4c02fecf9c Make test_mutants stronger by also adding random keys during comparisons.
A Mystery:  test_mutants ran amazingly slowly even before dictobject.c
"got fixed".  I don't have a clue as to why.  dict comparison was and
remains linear-time in the size of the dicts, and test_mutants only tries
100 dict pairs, of size averaging just 50.  So "it should" run in less than
an eyeblink; but it takes at least a second on this 800MHz box.
2001-05-10 20:18:30 +00:00
Tim Peters fd69208b78 Change test_mmap.py to use test_support.TESTFN instead of hardcoded "foo",
and wrap the body in try/finally to ensure TESTFN gets cleaned up no
matter what.
2001-05-10 20:03:04 +00:00
Tim Peters 8c3e91efaf Repair typos in comments. 2001-05-10 19:40:30 +00:00
Fred Drake e61967f537 Change some text just a little to avoid font-lock hell. 2001-05-10 18:41:02 +00:00
Fred Drake aaa48ff5c9 Extend the weakref test suite to cover the complete mapping interface for
both weakref.Weak*Dictionary classes.

This closes SF bug #416480.
2001-05-10 17:16:38 +00:00
Fred Drake 48a1638d78 Do no regenerate modules that should no longer be here. 2001-05-10 15:52:47 +00:00
Fred Drake a94414a287 Remove all remaining uses of the FCNTL module from the standard library. 2001-05-10 15:33:31 +00:00
Tim Peters 95bf9390a4 SF bug #422121 Insecurities in dict comparison.
Fixed a half dozen ways in which general dict comparison could crash
Python (even cause Win98SE to reboot) in the presence of kay and/or
value comparison routines that mutate the dict during dict comparison.
Bugfix candidate.
2001-05-10 08:32:44 +00:00
Fred Drake 66aaaae54c Update to reflect deprecation of the FCNTL module: The fcntl module does
*not* define O_RDWR; get that from the os module.
2001-05-10 05:17:02 +00:00
Steve Purcell 4bc808533f patch 418489 from Andrew Dalke for string format bug 2001-05-10 01:28:40 +00:00
Tim Peters 1ee77d9b71 Guido has Spoken. Restore strop.replace()'s treatment of a 0 count as
meaning infinity -- but at least warn about it in the code!  I pissed
away a couple hours on this today, and don't wish the same on the next
in line.
Bugfix candidate.
2001-05-10 01:23:39 +00:00
Tim Peters da45d55a6e The strop module and test_strop.py believe replace() with a 0 count
means "replace everything".  But the string module, string.replace()
amd test_string.py believe a 0 count means "replace nothing".
"Nothing" wins, strop loses.
Bugfix candidate.
2001-05-10 00:59:45 +00:00
Tim Peters 1a7b3eee94 SF bug #422088: [OSF1 alpha] string.replace().
Platform blew up on "123".replace("123", "").  Michael Hudson pinned the
blame on platform malloc(0) returning NULL.
This is a candidate for all bugfix releases.
2001-05-09 23:00:26 +00:00
Fred Drake 48871f2a6e Remove the old platform-specific FCNTL.py modules; these are no longer
needed now that fcntl exports the constants.
2001-05-09 21:15:06 +00:00
Fred Drake 76d6139961 Add a new FCNTL.py backward compatibility module that issues a deprecation
warning.  This is similar to the TERMIOS backward compatbility module.
2001-05-09 21:13:23 +00:00
Fred Drake bc7809b529 Update the tests for the fcntl module to check passing in file objects,
and using the constants defined there instead of FCNTL.
2001-05-09 21:11:59 +00:00
Jeremy Hylton e3e61049a5 Trivial tests of urllib2 for recent SF bug 2001-05-09 15:50:25 +00:00
Jeremy Hylton 78cae61ad4 Raise useful exception when called with URL for which request type
cannot be determined.

Pseudo-fix for SF bug #420724
2001-05-09 15:49:24 +00:00
Tim Peters 72f98e9b83 SF bug #422177: Results from .pyc differs from .py
Store floats and doubles to full precision in marshal.
Test that floats read from .pyc/.pyo closely match those read from .py.
Declare PyFloat_AsString() in floatobject header file.
Add new PyFloat_AsReprString() API function.
Document the functions declared in floatobject.h.
2001-05-08 15:19:57 +00:00
Tim Peters e63415ead8 SF patch #421922: Implement rich comparison for dicts.
d1 == d2 and d1 != d2 now work even if the keys and values in d1 and d2
don't support comparisons other than ==, and testing dicts for equality
is faster now (especially when inequality obtains).
2001-05-08 04:38:29 +00:00
Jeremy Hylton 4c889011db SF patch 419176 from MvL; fixed bug 418977
Two errors in dict_to_map() helper used by PyFrame_LocalsToFast().
2001-05-08 04:08:59 +00:00
Tim Peters 7ae2229afb 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.
2001-05-08 03:58:01 +00:00
Tim Peters 8572b4fedf 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?
2001-05-06 01:05:02 +00:00
Tim Peters ef0c42d4e5 Get rid of silly 5am "del" stmts. 2001-05-05 21:36:52 +00:00
Tim Peters cb8d368b82 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.
2001-05-05 21:05:01 +00:00
Tim Peters 75f8e35ef4 Generalize PySequence_Count() (operator.countOf) to work with iterators. 2001-05-05 11:33:43 +00:00
Tim Peters de9725f135 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__.
2001-05-05 10:06:17 +00:00
Tim Peters 2cfe368283 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).
2001-05-05 05:36:48 +00:00
Tim Peters 6912d4ddf0 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.
2001-05-05 03:56:37 +00:00
Tim Peters 15d81efb8a Generalize reduce() to work with iterators.
NEEDS DOC CHANGES.
2001-05-04 04:39:21 +00:00
Tim Peters 8bc10b0c57 Purge redundant cut&paste line. 2001-05-03 23:58:47 +00:00
Tim Peters 4e9afdca39 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.
2001-05-03 23:54:49 +00:00
Tim Peters efdae3939a Remove redundant copy+paste code. 2001-05-03 07:09:25 +00:00
Tim Peters c307453162 Generalize max(seq) and min(seq) to work with iterators.
NEEDS DOC CHANGES.
2001-05-03 07:00:32 +00:00
Fred Drake c7745d4b54 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).
2001-05-03 04:58:49 +00:00
Fred Drake a7cc69e02e Added support for .__contains__(), .__iter__(), .iterkeys(). 2001-05-03 04:55:47 +00:00
Fred Drake bedebbdfb1 Added support for .iteritems(), .iterkeys(), .itervalues(). 2001-05-03 04:54:41 +00:00
Fred Drake 72987a4b96 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.
2001-05-02 20:20:53 +00:00
Marc-André Lemburg 542fe56cb9 Fix for bug #417030: "print '%*s' fails for unicode string" 2001-05-02 14:21:53 +00:00
Tim Peters 0e57abf0cd Generalize filter(f, seq) to work with iterators. This also generalizes
filter() to no longer insist that len(seq) be defined.
NEEDS DOC CHANGES.
2001-05-02 07:39:38 +00:00
Tim Peters 8ae2df483c Whitespace normalization. 2001-05-02 05:54:44 +00:00
Fred Drake 0e540c391f Added tests for Weak*Dictionary iterator support.
Refactored some object initialization to be more reusable.
2001-05-02 05:44:22 +00:00
Fred Drake 101209d44c Added iterator support to the Weak*Dictionary classes. 2001-05-02 05:43:09 +00:00
Tim Peters f553f89d45 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)
2001-05-01 20:45:31 +00:00
Jeremy Hylton ddc4fd03b1 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.
2001-04-27 02:29:40 +00:00
Eric S. Raymond 53b809d673 Added more help, and recovery from misspelled sort key arguments. 2001-04-26 07:32:38 +00:00
Fred Drake 8f42e2b1fa 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.
2001-04-25 16:03:54 +00:00
Tim Peters c09cee4d92 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?
2001-04-25 03:43:14 +00:00
Andrew M. Kuchling b3ca303a4e Fix typo in docstring 2001-04-23 17:13:03 +00:00
Andrew M. Kuchling c42402fa19 Bump version # for final release 2001-04-23 16:01:06 +00:00
Guido van Rossum 8b48cf9016 Add test suite for iterators. 2001-04-21 13:33:54 +00:00
Tim Peters a3f98d6bac Give UserDict new __contains__ and __iter__ methods. 2001-04-21 09:13:15 +00:00
Guido van Rossum 59d1d2b434 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???)
2001-04-20 19:13:02 +00:00
Jeremy Hylton 12e73bb2f0 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.
2001-04-20 19:04:55 +00:00
Guido van Rossum 0dbb4fba4c 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.
2001-04-20 16:50:40 +00:00
Fred Drake bd7f818c50 Weak*Dictionary: Added docstrings to the classes.
Weak*Dictionary.update():  No longer create a temporary list to hold the
    things that will be stuffed into the underlying dictionary.  This had
    been done so that if any of the objects used as the weakly-held value
    was not weakly-referencable, no updates would take place (TypeError
    would be raised).  With this change, TypeError will still be raised
    but a partial update could occur.  This is more like other .update()
    implementations.

Thoughout, use of the name "ref" as a local variable has been removed.  The
original use of the name occurred when the function to create a weak
reference was called "new"; the overloaded use of the name could be
confusing for someone reading the code.  "ref" used as a variable name
has been replaced with "wr" (for 'weak reference').
2001-04-19 16:26:06 +00:00
Jeremy Hylton 12b6457e24 Fix compileall.py so that it fails on SyntaxErrors
The changes cause compilation failures in any file in the Python
installation lib directory to cause the install to fail.  It looks
like compileall.py intended to behave this way, but a change to
py_compile.py and a separate bug defeated it.

Fixes SF bug #412436

This change affects the test suite, which contains several files that
contain intentional errors.  The solution is to extend compileall.py
with the ability to skip compilation of selected files.

NB compileall.py is changed so that compile_dir() returns success only
if all recursive calls to compile_dir() also check success.
2001-04-18 01:20:21 +00:00
Jeremy Hylton 3090694068 Fix compileall.py so that it fails on SyntaxErrors
The changes cause compilation failures in any file in the Python
installation lib directory to cause the install to fail.  It looks
like compileall.py intended to behave this way, but a change to
py_compile.py and a separate bug defeated it.

Fixes SF bug #412436

This change affects the test suite, which contains several files that
contain intentional errors.  The solution is to extend compileall.py
with the ability to skip compilation of selected files.

In the test suite, rename nocaret.py and test_future[3..7].py to start
with badsyntax_nocaret.py and badsyntax_future[3..7].py.  Update the
makefile to skip compilation of these files.  Update the tests to use
the name names for imports.

NB compileall.py is changed so that compile_dir() returns success only
if all recursive calls to compile_dir() also check success.
2001-04-18 01:19:28 +00:00
Eric S. Raymond bc41957d2b Unused variable (caught by PyChecker) removed. 2001-04-17 17:20:19 +00:00
Jeremy Hylton 5030cf1c2d Fix three PyChecker-detected gotchas.
Import OPT_ symbols from _symtable.
Define has_exec() and has_import_star().
2001-04-16 18:43:18 +00:00
Guido van Rossum a490d5856d In walk(), don't die when os.lstat() raises os.error, e.g. because a
file was deleted by a previous call to the visitor function.

This used to be the behavior in 1.5.2 and before, but a patch to avoid
making two stat() calls accidentally broke this in 2.0.

Moshe, this would be a good one for 2.0.1 too!
2001-04-16 18:12:04 +00:00
Fred Drake a0a4ab1772 Add a test case for Weak*Dictionary.update() that would have caught a
recently reported bug; also exposed some other bugs in the implementation.
2001-04-16 17:37:27 +00:00
Fred Drake 1d9e4b7de3 Weak*Dictionary.update(): Fix calls to [].append() to only have one
parameter.

Weak*Dictionary.get():  Make the second parameter optional.

WeakKeyDictionary.has_key(), .keys():  Make these actually work!
2001-04-16 17:34:48 +00:00
Guido van Rossum 67addfe2a8 Implement Mark Favas's suggestion. There's a clear bug in _group():
its first return statement returns a single value while its caller
always expects it to return a tuple of two items.  Fix this by
returning (s, 0) instead.

This won't make the locale test on Irix succeed, but now it will fail
because of a bug in the platform's en_US locale rather than because of
a bug in the locale module.
2001-04-16 16:04:10 +00:00
Guido van Rossum 42f92da307 Change the test data to ask for class C from module __main__ rather
than from module pickletester.  Using the latter turned out to cause
the test to break when invoked as "import test.test_pickle" or "import
test.autotest".
2001-04-16 00:28:21 +00:00
Guido van Rossum b8bf3bece2 Fix SF bug [ #416231 ] urllib.basejoin fails to apply some ../.
Reported by Juan M. Bello Rivas.
2001-04-15 20:47:33 +00:00
Guido van Rossum 2b5ff073ab Get rid of the seek() method on the _Mailbox class. This was a
cut-and-paste copy of the seek() method on the _Subfile class, but it
didn't make one bit of sense: it sets self.pos, which is not used in
this class or its subclasses, and it uses self.start and self.stop,
which aren't defined on this class or its subclasses.  This is purely
my own fault -- I added this in rev 1.4 and apparently never tried to
use it.  Since it's not documented, and of very questionable use given
that there's no tell(), I'm ripping it out.

This resolves SF bug 416199 by Andrew Dalke: mailbox.py seek problems.
2001-04-15 13:32:27 +00:00
Guido van Rossum fc349862d4 In order to make this test work on Windows, the test locale has to be
set to 'en' there -- Windows does not understand the 'en_US' locale.
The test succeeds there.
2001-04-15 13:15:56 +00:00
Guido van Rossum 2d996c0704 Fix typo (missing "req." prefix on error_302_dict) found by Neil
Norwitz's PyChecker.
2001-04-15 13:08:01 +00:00
Guido van Rossum b8b45eac71 Fix typo in exception name (UnimplementedError should be
NotImplementedError) found by Neil Norwitz's PyChecker.
2001-04-15 13:06:04 +00:00
Guido van Rossum 74cde5bb3e Fix typo in exception name (SGMLParserError should be SGMLParseError)
found by Neil Norwitz's PyChecker.
2001-04-15 13:01:41 +00:00
Guido van Rossum 815bee4cf4 Fix typo in attribute name (file should be filename) found by
Neil Norwitz's PyChecker.
2001-04-15 12:51:42 +00:00
Guido van Rossum 0d1b7ea365 Fix typo in attribute name (chunk_size should be chunksize) found by
Neil Norwitz's PyChecker.
2001-04-15 12:40:13 +00:00
Steve Purcell ab0648ffc0 - Typo in message for TestCase.failIfEqual()
- Removed unused variable 'opts' in TestProgram.__init__ (thanks to PyChecker)
2001-04-15 09:18:32 +00:00
Guido van Rossum f3ee46b82a Set the SO_REUSEADDR socket option in the server thread -- this seems
needed on some platforms (e.g. Solaris 8) when the test is run twice
in quick succession.
2001-04-15 00:42:13 +00:00
Guido van Rossum f85af612f8 Mark Favas points out that there's an 'self.fp.flush()' call in the
ZipFile.close() method that should be part of the preceding 'if'
block.  On some platforms (Mark noticed this on FreeBSD 4.2) doing a
flush() on a file open for reading is not allowed.
2001-04-14 16:45:14 +00:00
Guido van Rossum b61914dd5b Pete Shinners discovered that zipfile.ZipFile() is called with mode
argument "wb", while the only valid modes are "r", "w" or "a".  Fix
this by changing the mode to "w".
2001-04-14 16:17:00 +00:00
Eric S. Raymond 3c1858a589 Should resolve [ #416039 ] pstats browser crashes. 2001-04-14 15:16:05 +00:00
Guido van Rossum 9df3eabd6e Add "import thread" at the top of the module; this prevents us from
failing later when Python is compiled without threading but a failing
'threading' module can be imported due to an earlier (caught) attempt.
2001-04-14 14:35:43 +00:00
Fred Drake b891891d00 If the sunaudiodev module is available but we cannot find an audio
device to use, skip this test instead of allowing an error to occur
when we attempt to play sound on the absent device.

Verified by Mark Favas.
2001-04-14 03:10:12 +00:00
Eric S. Raymond 9cb98572af Import readline when possible to make the commaninterpreter UI nicer. 2001-04-14 01:48:41 +00:00
Fred Drake 705088e65f Added regression test for SF bug #415660 (failure to invalidate all
references to an object before calling registered callbacks).

Change last uses of verify() to self.assert_().
2001-04-13 17:18:15 +00:00
Guido van Rossum 361c535863 Fix typo in comment (the module is now called _testcapi, not _test). 2001-04-13 17:03:04 +00:00
Jeremy Hylton c76770c68c Change error message raised when free variable is not yet bound. It
now raises NameError instead of UnboundLocalError, because the var in
question is definitely not local.  (This affects test_scope.py)

Also update the recent fix by Ping using get_func_name().  Replace
tests of get_func_name() return value with call to get_func_desc() to
match all the other uses.
2001-04-13 16:51:46 +00:00
Ka-Ping Yee d03f8fe95e One-character style change to appease Netscape stylesheets. 2001-04-13 15:04:32 +00:00
Ka-Ping Yee 6191a23537 Use nturl2path to generate a file: URL to source files in Windows. 2001-04-13 15:00:27 +00:00
Jeremy Hylton 79fa2b6073 Add test for SF bug #405427 2001-04-13 14:57:44 +00:00
Jeremy Hylton 23d4047790 SF patch #405845 by Martin von Löwis
Fixes SF bug #405427.
If an http response has a bogus return code, e.g. 400.100, raise
BadStatusLine.
2001-04-13 14:57:08 +00:00
Jeremy Hylton 3bee2f6011 Update to reflect new tokenize_test.py 2001-04-13 14:55:18 +00:00
Jeremy Hylton a4553c04fd There's no need for the tokenize tests to include a SyntaxError. 2001-04-13 14:36:51 +00:00
Ka-Ping Yee 022171fa21 Clean up isroutine(). 2001-04-13 14:04:02 +00:00
Ka-Ping Yee 9bc576b7f6 Use inspect.stack()[1][3] to tell if Helper.__repr__ is called interactively. 2001-04-13 13:57:31 +00:00
Ka-Ping Yee eca15c1fb1 Add inode checks to detect circular symbolic links (so that the
Tools/idle/idlelib link doesn't cause an infinite loop -- aack!)
2001-04-13 13:53:07 +00:00
Ka-Ping Yee 59685c5193 Small style change to accommodate Netscape. 2001-04-13 12:11:19 +00:00
Ka-Ping Yee c99e0f1862 Robustify getfile() against classes that lie about their __module__s
(such as the exceptions in _weakref and _locale!)
2001-04-13 12:10:40 +00:00
Ka-Ping Yee da79389f10 Word-wrap the list of cross-references. 2001-04-13 11:02:51 +00:00
Ka-Ping Yee 79c009d767 Another pass through the topic table to fill in cross references.
Restore Helper.__repr__ for now.
2001-04-13 10:53:25 +00:00
Ka-Ping Yee dec96e92ae Make force-loading optional; don't force-load in interactive mode.
Make synopsis() load modules as '__temp__' so they don't clobber anything.
Change "constants" section to "data" section.
Don't show __builtins__ or __doc__ in "data" section.
For Bob Weiner: don't boldface text in Emacs shells or dumb terminals.
Remove Helper.__repr__ (it really belongs in site.py, and should be                 guarded by a check for len(inspect.stack) <= 2).
2001-04-13 09:55:49 +00:00
Ka-Ping Yee 202c99b2e0 Remove duplicate type objects from isroutine() and isbuiltin().
Make getmodule() on a module return the module itself.
2001-04-13 09:15:08 +00:00
Martin v. Löwis 88ad12afac Patch #415777: new grouping strategy.
fixes bug #414940, and redoes the fix for #129417 in a different way.
It also fixes a number of other problems with locale-specific formatting:
If there is leading or trailing spaces, then no grouping should be applied
in the spaces, and the total length of the string should not be changed
due to grouping.
Also added test case which works only if the en_US locale is available.
2001-04-13 08:09:50 +00:00
Tim Peters 613b2222cf Whitespace normalization. 2001-04-13 05:37:27 +00:00
Eric S. Raymond 4f3980d3cb Added a test main to the pstats library that can help you browse profile dumps. 2001-04-13 00:23:01 +00:00
Fred Drake f4e5bd9df5 _synthesize(): Helper function: when the users passes a specific
value for the 'using' parameter of the get() function
                or the BROWSER environment variable, if the thing
                passed in is a path (as seems to be the case with KDE)
                instead of a short name, examine the available
                controllers to see if we can synthesize one based on a
                pre-registered controller that shares the same base
                name.

get():  If the user specifies a browser we don't know about, use
        _synthesize() to attempt to create a usable controller.

Some small adjustments were needed in some of the browser classes to
support this.
2001-04-12 22:07:27 +00:00
Jeremy Hylton bb0bae6da2 Pop loop off the loop stack before handling the loop's else clause.
Otherwise, continue/break will attempt to affect the wrong loop.

A few more fiddles to get the SET_LINENOs consistent across compilers.
2001-04-12 21:54:41 +00:00
Jeremy Hylton 13d70944cb Use new _implicitNameOp() to generate name op code for list comprehensions.
Always emit a SET_LINENO 0 at the beginning of the module.  The
builtin compiler does this, and it's much easier to compare bytecode
generated by the two compilers if they both do.

Move the SET_LINENO inside the FOR_LOOP block for list
comprehensions.  Also for compat. with builtin compiler.
2001-04-12 21:04:43 +00:00
Ka-Ping Yee b7a48300cd Fix linking to classes (in class tree, and add links on unbound methods). 2001-04-12 20:39:14 +00:00
Ka-Ping Yee 6dcfa3884d Fix call to ModuleScanner from GUI search interface.
Fix handling of unbound top-level methods.
2001-04-12 20:27:31 +00:00
Jeremy Hylton 614e87f286 Add support for visitAssAttr to findOp(). 2001-04-12 20:24:26 +00:00
Jeremy Hylton 542b11acfd pyassem.py:
Fix annoying bugs in flow graph layout code.  In some cases the
    implicit control transfers weren't honored.  In other cases,
    JUMP_FORWARD instructions jumped backwards.

    Remove unused arg from nextBlock().

pycodegen.py

    Add optional force kwarg to set_lineno() that will emit a
    SET_LINENO even if it is the same as the previous lineno.

    Use explicit LOAD_FAST and STORE_FAST to access list comp implicit
    variables.  (The symbol table doesn't know about them.)
2001-04-12 20:21:39 +00:00
Ka-Ping Yee 35cf0a3f90 Added a big new Helper class to provide interactive help! 2001-04-12 19:53:52 +00:00
Tim Peters fff5325078 Bug 415514 reported that e.g.
"%#x" % 0
blew up, at heart because C sprintf supplies a base marker if and only if
the value is not 0.  I then fixed that, by tolerating C's inconsistency
when it does %#x, and taking away that *Python* produced 0x0 when
formatting 0L (the "long" flavor of 0) under %#x itself.  But after talking
with Guido, we agreed it would be better to supply 0x for the short int
case too, despite that it's inconsistent with C, because C is inconsistent
with itself and with Python's hex(0) (plus, while "%#x" % 0 didn't work
before, "%#x" % 0L *did*, and returned "0x0").  Similarly for %#X conversion.
2001-04-12 18:38:48 +00:00
Jeremy Hylton bfb0cf822b Revise handling of tuple arguments so that the variables names match
those used by compile.c.  (test_grammar now depends on the names)
2001-04-12 17:33:34 +00:00
Ka-Ping Yee 131216290b Give up trying to keep dynamically loaded extensions up to date:
the import.c machinery has soundly defeated my every attempt.
2001-04-12 13:37:39 +00:00
Ka-Ping Yee b910efe8a9 Robustify getcomments() so it doesn't crash on empty files. 2001-04-12 13:17:17 +00:00
Ka-Ping Yee fd540695e7 Remove forking. Doesn't work in Windows. 2001-04-12 12:54:36 +00:00
Ka-Ping Yee 662469619a Typo fixes and small touches. 2001-04-12 11:59:50 +00:00
Ka-Ping Yee 9aa0d90947 Properly qualify methods inherited from classes in other modules.
Fix so that docother() doesn't blow up.
Eliminate man() function since doc() and man() did nearly the same thing.
Various other code cleanup and refactoring to reduce duplication.
Simplify and rewrite freshimport() so modules are always up to date,
    even within packages (where reload() doesn't work).
Add finalization callback to the server (so that if the server fails to
    start for some reason, the main thread isn't left hanging).
2001-04-12 10:50:23 +00:00
Steve Purcell 15d8927f7e - New fail*() methods, and comprehensive set of assert*() synonyms
- TestCase.failureException defines the exception that indicates a test failure
- Docstrings for TestLoader class
- Added exc_info() hack back in
2001-04-12 09:05:01 +00:00
Jeremy Hylton 5c9aad6043 Only treat an AugAssign as def if its the target is a Name.
Fixes last bug found with test_scope.py.
2001-04-12 07:06:25 +00:00
Jeremy Hylton 3f76b7e6e4 Fix unpackSequence() to use _nameOp() rather than LOAD_FAST 2001-04-12 06:52:27 +00:00
Jeremy Hylton 660cc77abb Inside a class scope always use LOAD_NAME, STORE_NAME, DEL_NAME 2001-04-12 06:49:00 +00:00
Jeremy Hylton 364f9b9e2f Preliminary support for nested scopes
XXX Still doesn't work right for classes
XXX Still doesn't do sufficient error checking
2001-04-12 06:40:42 +00:00
Jeremy Hylton 53ee2a94c7 Define constants for types of scopes 2001-04-12 06:39:24 +00:00
Tim Peters 711088d9b8 Fix for SF bug #415514: "%#x" % 0 caused assertion failure/abort.
http://sourceforge.net/tracker/index.php?func=detail&aid=415514&group_id=5470&atid=105470
For short ints, Python defers to the platform C library to figure out what
%#x should do.  The code asserted that the platform C returned a string
beginning with "0x".  However, that's not true when-- and only when --the
*value* being formatted is 0.  Changed the code to live with C's inconsistency
here.  In the meantime, the problem does not arise if you format a long 0 (0L)
instead.  However, that's because the code *we* wrote to do %#x conversions on
longs produces a leading "0x" regardless of value.  That's probably wrong too:
we should drop leading "0x", for consistency with C, when (& only when) formatting
0L.  So I changed the long formatting code to do that too.
2001-04-12 00:35:51 +00:00
Tim Peters 4642cb9ac9 Reverting the "unixware7" patch: atan2(0, 1) should be 0, regardless of
platform.  If it returns pi on the unixware7 platform, they have a bug in
their libm atan2.
2001-04-12 00:24:41 +00:00
Guido van Rossum ac6985f42f SOCKET.py and TERMIOS.py are no longer used in this release. 2001-04-11 23:43:09 +00:00
Guido van Rossum 2242f2fbd0 Unixware 7 support by Billy G. Allie (SF patch 413011) 2001-04-11 20:58:20 +00:00
Jeremy Hylton 84ec1f9159 typo 2001-04-11 16:43:13 +00:00
Jeremy Hylton 01d12937df [finishing fix from earlier checkins]
Call set_lineno() in visitDiscard(), which will generate linenos for
discard statements, e.g. the statement "1/0"

Fixes SF bug #409587
2001-04-11 16:36:25 +00:00
Jeremy Hylton d91bbba89d Add support for extra (*) arguments to preorder.
Change default dispatch to use extended call syntax in place of apply.
2001-04-11 16:26:05 +00:00
Jeremy Hylton 9ab019bee7 Generate docstrings.
Fixes SF buf #217004

Add method fixDocstring() to CodeGenerator.  It converts the Discard
node containing the docstring into an assignment to __doc__.
2001-04-11 16:24:30 +00:00
Jeremy Hylton 4c1f42733c Add lineno attributes to Discard nodes 2001-04-11 16:22:26 +00:00
Jeremy Hylton 5af105eec9 Make sure the docstring is always entered as the first element in the
consts, even if it is None.

Simplify _lookupName() by removing lots of redundant tests.
2001-04-11 16:21:51 +00:00
Jeremy Hylton ceccc3c037 Test cases for examples of ext call error handling.
Fix to SF bug #414743 based on Michael Hudson's patch #414750.
2001-04-11 13:53:35 +00:00
Moshe Zadka 7667680d70 Idiotic braino caused HTTP openers to ignore proxies.
This fixes 413135
2001-04-11 07:44:53 +00:00
Ka-Ping Yee 285a7e59f3 Add a close_request method to the BaseServer so that the TCPServer class
can close the request connection when it's done handling it.
2001-04-11 04:02:05 +00:00
Guido van Rossum bceccf5f43 Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger 2001-04-10 22:07:43 +00:00
Guido van Rossum 40f3c7fdf0 The lower() and tkraise() methods were calling the Canvas widget
wrongly.  Fixed this.

This closes SF bug #412682.
2001-04-10 21:13:06 +00:00
Fred Drake 9a9d219f07 mapping(): Remove this function since it does not add anything to the API. 2001-04-10 19:11:23 +00:00
Fred Drake bf43691ccb Use the WeakKeyDictionary and WeakValueDictionary classes directly
instead of using the mapping() function.
2001-04-10 19:09:35 +00:00
Thomas Heller f6cdead8e9 Since bdist_wininst.py contains the installer executable, it had to be
rebuild.
2001-04-10 18:57:07 +00:00
Guido van Rossum e9901f325e Fix two unqualified except: clauses.
This came out of SF bug #411881.
2001-04-10 15:44:33 +00:00
Guido van Rossum 6274fff287 Fix an unqualified except:.
This came out of SF bug #411881.
2001-04-10 15:42:02 +00:00
Guido van Rossum 9c673f35d2 Try an except: after an import into "except ImportError".
This came out of SF bug #411881.

Note that there's another unqualified except: still.
2001-04-10 15:37:12 +00:00
Guido van Rossum 75ebb29f88 Some other tests, when failing, don't always remove their TESTFN file.
Try to do it for them, so our mkdir() operation doesn't fail.
2001-04-10 15:01:20 +00:00
Guido van Rossum a5af2148ee When doing the quick test to see whether large files are supported,
catch IOError as well as OverflowError.  I found that on Tru64 Unix
this was raised; probably because the OS (or libc) doesn't support
large files but the architecture is 64 bits!
2001-04-10 14:50:51 +00:00
Guido van Rossum bfce016a30 When zlib can't be imported, zipfile raises RuntimeError, which causes
the test to be marked as failing rather than skipped.  Add an explicit
"import zlib" to prevent this.
2001-04-10 14:46:39 +00:00
Ka-Ping Yee 41763b9603 Fix typo in instantiation of ErrorDuringImport. 2001-04-10 12:22:01 +00:00
Ka-Ping Yee 5a804edd3c Fix synopsis() so it can handle binary module files.
Avoid ever using popen on Windows, since it's broken there.
Factor out the business of getting the summary line into splitdoc().
Use the modulename() routine in inspect.
Show all members of modules and classes rather than filtering on leading '_'.
Small typo and formtating fixes.
Don't show warnings when running "pydoc -k".
2001-04-10 11:46:02 +00:00
Ka-Ping Yee 4d6fc7fae1 Add getmodulename() and getmoduleinfo() routines to inspect filenames. 2001-04-10 11:43:00 +00:00
Tim Peters 44714007e8 test_pickle works on sizeof(long)==8 boxes again.
pickle.py
    The code implicitly assumed that all ints fit in 4 bytes, causing all
    sorts of mischief (from nonsense results to corrupted pickles).
    Repaired that.
marshal.c
    The int marshaling code assumed that right shifts of signed longs
    sign-extend.  Repaired that.
2001-04-10 05:02:52 +00:00
Tim Peters e089c68871 Test full range of native ints. This exposes two more binary pickle
bugs on sizeof(long)==8 machines.  pickle.py has no idea what it's
doing with very large ints, and variously gets things right by accident,
computes nonsense, or generates corrupt pickles.  cPickle fails on
cases 2**31 <= i < 2**32:  since it *thinks* those are 4-byte ints
(the "high 4 bytes" are all zeroes), it stores them in the (signed!) BININT
format, so they get unpickled as negative values.
2001-04-10 03:41:41 +00:00
Tim Peters c32d824467 Mechanical fiddling for easier reading: every "if" test was enclosed in
parens, but no "while" test.  Removed the former.
2001-04-10 02:48:53 +00:00
Jeremy Hylton dbdb28e8be Add globals to list of names returned by get_names().
Fix func arg processing to handle args in tuples.
In test code, skip names beginning with '.'.
2001-04-09 20:11:59 +00:00
Tim Peters 461922a005 Pickles have a number of storage formats for various sizes and kinds of
integers, but the std tests don't exercise most of them.  Repair that.

CAUTION:  I expect this to fail on boxes with sizeof(long)==8, in the
part of test_cpickle (but not test_pickle) trying to do a binary mode
(not text mode) load of the embedded BINDATA pickle string.  Once that
hypothesized failure is confirmed, I'll fix cPickle.c.
2001-04-09 20:07:05 +00:00
Tim Peters c58440fcef No functional change -- just added whitespace in places so I could follow
the logic better.  Will be adding some additional tests later today.
2001-04-09 17:16:31 +00:00
Steve Purcell 17a781bc69 * Remove exc_info() kludge -- it actually messed up the Jython output
* Fixed TestLoader.loadTestsFromName() for nested packages
* Corrected the command-line usage summary
2001-04-09 15:37:31 +00:00
Moshe Zadka 5d87d47295 fixing 408085 - redirect from https becomes http
Even though relative redirects are illegal, they are common
urllib treated every relative redirect as though it was to http,
even if the original was https://
As long as we're compensating for server bugs, might as well do
it properly.
2001-04-09 14:54:21 +00:00
Jeremy Hylton f870c952f9 Add two arguments to Scope constructor, module scope and class name
Add mangling support
Add get_children() and add_child() methods to Scope
Skip nodes when If test is a false constant
Add test code that checks results against symtable module
2001-04-09 13:57:32 +00:00
Jeremy Hylton 8b966dcf03 Add preliminary module symbol table constructor 2001-04-09 04:35:35 +00:00
Jeremy Hylton 0e8468c8ba remove global decl about unused variable 2001-04-09 04:31:50 +00:00
Jeremy Hylton 80e29bd139 Add support for future statements 2001-04-09 04:28:48 +00:00
Jeremy Hylton 42a0830713 Fix "import as" (has always skipping the as name)
Fix com_NEWLINE() so that is accepts arguments, which occurs for lines like:
    stmt; # note trailing semicolon
Add XXX about checking for assignment to list comps
2001-04-09 04:27:12 +00:00
Jeremy Hylton a384f737cc typo 2001-04-09 04:23:55 +00:00
Guido van Rossum 9cec8fba06 Make it clear that a bdb subclass must implement do_clear().
This was found by Neal Norwitz's PyChecker.
2001-04-08 15:05:16 +00:00
Tim Peters 7e01e284cb Whitespace normalization. 2001-04-08 07:44:07 +00:00
Tim Peters 6fd7120616 Fix from the Madusa mailing list:
http://groups.yahoo.com/group/medusa/message/333

It's clear that Medusa should not be checking for an empty buffer
via "buf is ''".  The patch merely changes "is" to "==".  However,
there's a mystery here all the same:  Python attempts to store null
strings uniquely, so it's unclear why "buf is ''" ever returned
false when buf actually was empty.  *Some* string operations produce
non-unique null strings, e.g.

>>> "abc"*0 is "abc"*0
0
>>>

but they're rare, and I don't see any such operations in asynchat.
2001-04-08 07:23:44 +00:00
Tim Peters cfc21fcf48 Remove useless imports, as reported by PyChecker. 2001-04-08 00:43:13 +00:00
Tim Peters 3664111fb1 Get rid of useless string import, as reported by Neal Norwitz's PyChecker.py
on c.l.py.
2001-04-08 00:38:42 +00:00
Greg Stein 76977bbcaf Add an uninstall method to the ImportManager.
This is the accepted portion of patch #402498.
2001-04-07 16:05:24 +00:00
Tim Peters eb26f95906 Since Guido fiddled Cookie.py to work with doctest, it's a Good Thing to
have the std test suite exercise the Cookie doctests too.
2001-04-06 21:20:58 +00:00
Guido van Rossum 58b6f5b53e Since this module already uses doctest-style examples, I figured I'd
add a self-test using doctest.  Results:

- The docstring needs to be a raw string because it uses \"...\".

- The oreo example was broken: the Set-Cookie output doesn't add
  quotes around "doublestuff".

- I had to change the example that prints the class of a Cookie.Cookie
  instance to avoid incorporating an arbitrary object address in the
  test output.

Pretty good score for both doctest and the doc string, I'd say!
2001-04-06 19:39:11 +00:00
Tim Peters f95423e265 Remove lines for asynchat & asyncore, as they've now got their own test. 2001-04-06 18:59:17 +00:00
Guido van Rossum dca060c55c After testing the test on Unix, several improvements:
- Use push() instead of send(), and make these calls in main().

- Sleep a second to give the server thread time to initialize itself.
2001-04-06 16:43:49 +00:00
Guido van Rossum 66172520ee Add test for asynchat. This also tests asyncore. 2001-04-06 16:32:22 +00:00
Guido van Rossum e4a1b6d7c4 Make the docstring a raw string, for pydoc.
(How many opre of these will we need? :-( )
2001-04-06 15:30:33 +00:00
Tim Peters b5d1392d92 Fix the fix (my error -- hasty pasty). 2001-04-05 22:38:32 +00:00
Tim Peters a29b6222fe One-liner critical fix from Jim Fulton: Eric's string-method crusade
got the order backwards in a line (for .find()).
2001-04-05 22:26:23 +00:00
Andrew M. Kuchling 37f0263811 Bug #412086, reported by Peter Wilson: The _curses module doesn't
define COLORS or COLOR_PAIRS until after start_color() is called,
    but they were never added to the curses module.  Fixed by adding
    a wrapper around start_color(), similar to the wrapper around initscr().
2001-04-05 16:08:41 +00:00
Andrew M. Kuchling 7880e5ecd7 Patch #413912 from Steve Majewski: Add .m to the list of extensions
in order to support Objective-C.
2001-04-05 15:46:48 +00:00
Fred Drake dc806704b5 Corrected default value of the DocumentType.internalSubset attribute based
on a clarification sent to the www-dom list.
2001-04-05 14:41:30 +00:00
Tim Peters 7d3bad66e4 Sf bug [ #412214 ] ZipFile constructor leaves files open.
This applies the patch Fred Drake created to fix it.
I'm checking it in since I had to apply the patch anyway in order
to test its behavior on Windows.
2001-04-04 18:56:49 +00:00