Commit Graph

7593 Commits

Author SHA1 Message Date
Tim Peters dbaba0d05a Added basic tests of copy_reg's extension registry. 2003-02-04 17:49:36 +00:00
Walter Dörwald 5e61e24d55 Add a test that checks that filter() honors the sq_item slot for
str and unicode subclasses not just for generating the output
but for testing too.
2003-02-04 17:04:01 +00:00
Walter Dörwald 903f1e0c40 filterstring() and filterunicode() in Python/bltinmodule.c
blindly assumed that tp_as_sequence->sq_item always returns
a str or unicode object. This might fail with str or unicode
subclasses.

This patch checks whether the object returned from __getitem__
is a str/unicode object and raises a TypeError if not (and
the filter function returned true).

Furthermore the result for __getitem__ can be more than one
character long, so checks for enough memory have to be done.
2003-02-04 16:28:00 +00:00
Jack Jansen 57ba55b77d - Handle the img and MediaFormat modules not being available (by not
providing the format info, only the raw data).
- Get rid of fsspecs.
- Make the demo program at least do something if img not available.
2003-02-04 15:36:42 +00:00
Raymond Hettinger 105b084b59 Add refcount test. 2003-02-04 05:47:30 +00:00
Tim Peters 2d62965734 cPickle can load pickles using proto 2 EXT[124] now, but can't yet
generate these opcodes.
2003-02-04 05:06:17 +00:00
Guido van Rossum d4b920c8bd Rename the extension registry variables to have leading underscores --
this clarifies that they are part of an internal API (albeit shared
between pickle.py, copy_reg.py and cPickle.c).

I'd like to do the same for copy_reg.dispatch_table, but worry that it
might be used by existing code.  This risk doesn't exist for the
extension registry.
2003-02-04 01:54:49 +00:00
Tim Peters 322d553143 Whitespace normalization. 2003-02-04 00:38:20 +00:00
Tim Peters 5b7da39f23 Brought some module variables into synch with pickle.py's current values.
Imported the extension-registry dicts from copy_reg.py, in preparation for
tackling EXT[124].
2003-02-04 00:21:07 +00:00
Walter Dörwald e7028ac56c Fix typo. 2003-02-03 23:05:27 +00:00
Walter Dörwald c3502467d4 Add a new test script that tests various features of the sys
module. This increases code coverage of Python/sysmodule.c
from 68% to 77% (on Linux).

The script doesn't exercise the error branch that handles an evil
or lost sys.excepthook in Python/pythonrun.c::PyErr_PrintEx().

Also this script might not work on Jython in its current form.

From SF patch #662807.
2003-02-03 23:03:49 +00:00
Tim Peters 894453a28d test_newobj_tuple(), test_newobj_list(): These tests should work under
all protocols, so tried them under all.
2003-02-03 22:32:18 +00:00
Tim Peters 5013bd9438 test_newobj_generic(): Use the global protocols vector instead of a
hardcoded list.
2003-02-03 22:28:41 +00:00
Tim Peters 22e71711b3 Added a bit to the EXT[124] tests, and refactored them to squash code
duplication.  Note that these still don't get run under cPickle.
2003-02-03 22:27:38 +00:00
Tim Peters 61bf257633 Do a better job of testing that opcodes aren't generated under protocols
earlier than the ones in which they were introduced.
2003-02-03 21:31:22 +00:00
Guido van Rossum 7d9ea5013f - Thanks to Scott David Daniels, a subtle bug in how the zlib
extension implemented flush() was fixed.  Scott also rewrite the
  zlib test suite using the unittest module.  (SF bug #640230 and
  patch #678531.)

Backport candidate I think.
2003-02-03 20:45:52 +00:00
Walter Dörwald 88af4dfa4b Fix typos. 2003-02-03 20:22:27 +00:00
Walter Dörwald 363f6d65a7 Port test_pow.py to PyUnit. From SF patch #662807 2003-02-03 20:17:19 +00:00
Guido van Rossum 93fe564217 _slotnames(): this is a fairly expensive calculation. Cache the
outcome as __slotnames__ on the class.  (Like __slots__, it's not safe
to ask for this as an attribute -- you must look for it in the
specific class's __dict__.  But it must be set using attribute
notation, because __dict__ is a read-only proxy.)
2003-02-03 19:46:54 +00:00
Andrew M. Kuchling 2de97d398d [Bug #676292] BaseHTTPServer incorrectly parses protocol; fix by Andrew Dalke
* Treat major, minor numbers of HTTP version as separate integers
   * Fix errors if version string is "HTTP/1.2.3" or even simply "BLAH".
   * send_error() checks if 'self.command' is a
     HEAD.  However, if there's an error parsing the first line of the
     HTTP request the self.command wasn't set yet; force
     self.command to be initialized to None.
2003-02-03 19:11:18 +00:00
Guido van Rossum 868ecc22ab _slotnames(): exclude __dict__ and __weakref__; these aren't real
slots even though they can be listed in __slots__.
2003-02-03 18:10:09 +00:00
Guido van Rossum 795ea89cb5 Support keyword argument 'bin', with a pending deprecation warning. 2003-02-03 16:59:48 +00:00
Tim Peters 31f119ebdb Proper testing of proto 2 in part requires checking that the new opcodes
are actually getting generated.  Add helpered method
ensure_opcode_in_pickle to do a correct job checking for that.  Changed
test_long1(), test_long4(), and test_short_tuples() to use it.
2003-02-03 16:20:13 +00:00
Guido van Rossum 7aa56c9a7f test_float_overflow(): make shuge (added last week) a little less
huge.  On older Linux systems, the C library's strtod() apparently
gives up before seeing the end of the string when it sees so many
digits that it thinks the result must be Infinity.  (It is wrong, BTW
-- there could be an "e-10000" hiding behind 10,000 digits.)  The
shorter shuge still tests what it's testing, without relying on
strtod() doing a super job.
2003-02-03 15:25:01 +00:00
Andrew M. Kuchling 8ca202e395 Bug #676273: Rewrite paragraph in module docstring 2003-02-03 15:21:15 +00:00
Fred Drake 9a0db07c2f test_support.requires(): Instead of raising TestSkipped, raise a new
exception, ResourceDenied.  This is used to distinguish between tests that
are skipped for other reasons (platform support, missing data, etc.) from
those that are skipped because a "resource" has not been enabled.  This
prevents those tests from being reported as unexpected skips for the
platform; those should only be considered unexpected skips if the resource
were enabled.
2003-02-03 15:19:30 +00:00
Greg Ward 4c6c9c42fb Add __all__ (suggested by Raymond Hettinger).
Rename 'whitespace' global to '_whitespace' -- it's not part of the
public interface.
2003-02-03 14:46:57 +00:00
Walter Dörwald 7a2d7a74fc Remove test_b1 and test_b2 from the list of tests
that are no real tests, because test_b1 and
test_b2 no longer exist. (Spotted by Raymond Hettinger)
2003-02-03 11:54:39 +00:00
Just van Rossum ca3fec7162 patch #664131, fix config command on OSX and Linux 2003-02-03 11:43:54 +00:00
Michael W. Hudson 35a92ce9da Fix bug
[ 676342 ] after using pdb readline does not work correctly

using Michael Stone's patch so the completer functionality of
cmd is only setup between preloop and postloop.
2003-02-03 11:04:27 +00:00
Gregory P. Smith bc2adef898 fix for use on python 2.1 2003-02-03 04:19:40 +00:00
Guido van Rossum 49992f9d25 cPickle now implements enough of protocol 2 to enable all
cross-pickling tests.
2003-02-03 01:32:33 +00:00
Walter Dörwald 7f3ed74643 Fix typos. 2003-02-02 23:08:27 +00:00
Jack Jansen cc94764c67 Getting rid of macfs usage and almost all FSSpecs. Untested on MacOS9. 2003-02-02 23:03:50 +00:00
Tim Peters 1d63c9f151 cPickle support for TUPLE[123]. Incidentally plugged several undetected
overflow holes in Pdata_grow().
2003-02-02 20:29:39 +00:00
Just van Rossum 9af6968b90 jeez, now I know why I shouldn't even _want_ to learn sh. 2003-02-02 18:56:37 +00:00
Tim Peters 3c67d795ef Implemented proto 2 NEWTRUE and NEWFALSE in cPickle. 2003-02-02 17:59:11 +00:00
Tim Peters 70b02d79f9 Beefed up the tests by putting in more "for proto in protocols:" outer
loops.  Renamed DATA and BINDATA to DATA0 and DATA1.  Included
disassemblies, but noted why we can't test them.  Added XXX comment to
cPickle about a mysterious comment, where pickle and cPickle diverge
in how they number PUT indices.
2003-02-02 17:26:40 +00:00
Tim Peters 4190fb8429 Add cPickle support for PROTO. Duplicated PROTO/LONG1/LONG4 code in
the hitherto unknown (to me) noload() cPickle function, which is (a)
something we don't test at all, and (b) pickle.py doesn't have.
2003-02-02 16:09:05 +00:00
Raymond Hettinger 1ecfb73c26 One more use of ifilter() 2003-02-02 16:07:53 +00:00
Raymond Hettinger a3a53180c0 SF patch #678899: Save time and memory by using itertools in sets module. 2003-02-02 14:27:19 +00:00
Tim Peters bf2674be0e long(string, base) now takes time linear in len(string) when base is a
power of 2.  Enabled the tail end of test_long() in pickletester.py
because it no longer takes forever when run from test_pickle.py.
2003-02-02 07:51:32 +00:00
Tim Peters ee1a53cbb1 cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments.  Fixed an undetected-overflow bug in readline_file().

longobject.c:  Fixed a really stupid bug in the new _PyLong_NumBits.

pickle.py:  Fixed stupid bug in save_long():  When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4():  they *returned* the unpickled long instead of pushing
it on the stack.  The return values were ignored.  Tests passed
before only because save_long() pickled the long twice.

Fixed bugs in encode_long().

Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time.  I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that.  It would be more valuable to make long(string, 16) linear time.

pickletester.py:  Added a global "protocols" vector so tests can try
all the protocols in a sane way.  Changed test_ints() and test_unicode()
to do so.  Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle:  cPickle proto 2 for longs is linear-time).
2003-02-02 02:57:53 +00:00
Tim Peters 5bd2a79b22 The C pickle now knows how to deal with a proto= argument. Assorted
code cleanups, and purged more references to text-vs-binary modes.
2003-02-01 16:45:06 +00:00
Just van Rossum a212c5c37f removed bizarre construct, no idea why it was there... 2003-02-01 10:29:45 +00:00
Just van Rossum 2aa09566c5 icon support by Robin Dunn, closes patch #678218 2003-02-01 08:34:46 +00:00
Tim Peters b57f8f02ba There's no good reason for datetime objects to expose __getstate__()
anymore either, so don't.  This also allows to get rid of obscure code
making __getnewargs__ identical to __getstate__ (hmm ... hope there
wasn't more to this than I realize!).
2003-02-01 02:54:15 +00:00
Raymond Hettinger 874d9bcbe5 Neaten ref count test. 2003-02-01 02:33:45 +00:00
Tim Peters 1f1b2d2e68 Removed all uses of the out-of-favor __safe_for_unpickling__ magic
attr, and copy_reg.safe_constructors.
2003-02-01 02:16:37 +00:00
Raymond Hettinger 96ef8115dd Move itertools module from the sandbox and into production. 2003-02-01 00:10:11 +00:00