Commit Graph

7621 Commits

Author SHA1 Message Date
Guido van Rossum 5aac4e6312 Move _better_reduce from copy.py to copy_reg.py, and also use it in
pickle.py, where it makes save_newobj() unnecessary.  Tests pass.
2003-02-06 22:57:00 +00:00
Guido van Rossum 85233bf746 Fix a bug in the way __getnewargs__ was handled. 2003-02-06 21:25:12 +00:00
Guido van Rossum c755758906 Support all the new stuff supported by the new pickle code:
- subclasses of list or dict
- __reduce__ returning a 4-tuple or 5-tuple
- slots
2003-02-06 19:53:22 +00:00
Andrew M. Kuchling 0189266456 A few naughty external scripts do 'raise getopt.error, "blah"', and
now crash because two arguments are expected.  Add a default value
   to keep those scripts running.
2003-02-06 19:52:56 +00:00
Andrew M. Kuchling 83e879d99f Add DeprecationWarning when use_statcache argument is supplied
Fix use of GetoptError, so demo() now works
2003-02-06 19:38:45 +00:00
Guido van Rossum 98b922c0ec Remove a debug print statement. 2003-02-06 19:30:38 +00:00
Guido van Rossum 90e05b0e25 Support __reduce__ returning a 4-tuple or 5-tuple. 2003-02-06 18:18:23 +00:00
Guido van Rossum 581cb938d0 A test suite for the copy module. This should provide full code
coverage.
2003-02-06 17:52:15 +00:00
Andrew M. Kuchling 8eb4044f7e [Bug #680494] filecmp.py uses obsolete statcache module.
Simply replace all uses of statcache with os.stat.

Should I add a DeprecationWarning triggered if the use_statcache argument
is supplied, so we can remove it in 2.4?
2003-02-06 17:50:01 +00:00
Andrew M. Kuchling e63846dc3a Add test suite for filecmp.py, after some discussion on bug #680494.
Right now the test cases create a files and a directory in the temp.
directory.  Raymond suggested checking files in to the test/ directory,
simplifying the setup/teardown methods; is that worth doing?
2003-02-06 17:42:45 +00:00
Tim Peters 844076122e SF bug 680864: test_datetime fails for non-unix epoch
Apparently MAC OS 9 doesn't have POSIX-conforming timestamps.  A test
fails as a result, but at least for this specific test it's easy enough
to get the POSIX epoch out of it.
2003-02-06 16:42:14 +00:00
Jeremy Hylton cc1fccbc1c No need for a continuation line. 2003-02-06 16:23:01 +00:00
Jeremy Hylton 656d4519b5 Replace hasattr() + getattr() with single getattr() and default value. 2003-02-06 16:22:01 +00:00
Anthony Baxter 983b008824 Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
This patch adds stdin, stdout as optional arguments to the cmd.Cmd
constructor (defaulting to sys.stdin, sys.stdout), and changes the Cmd
methods throughout to use self.stdout.write() and self.stdin.foo for
output and input. This allows much greater flexibility for using cmd -
for instance, hooking it into a telnet server.

Patch for library module and for documentation.
2003-02-06 01:45:11 +00:00
Andrew M. Kuchling 64edd6ac1d [Patch #654421 from Matthew Mueller]
gzip shouldn't raise ValueError on corrupt files

  Currently the gzip module will raise a ValueError if the file was
  corrupt (bad crc or bad size).  I can't see how that applies to
  reading a corrupt file.  IOError seems better, and it's what code
  will likely be looking for.
2003-02-05 21:35:07 +00:00
Tim Peters 62235e701e dis(): Added an optional memo argument, so that multiple pickles in a
file can be dumped without (bogus) complaint if the the pickles were
created using a single pickle memo.
2003-02-05 19:55:53 +00:00
Tim Peters 6ee0480521 [680789] Debug with long array takes forever
Added array.array to the types repr.py knows about, after a suggestion
from Jurjen N.E. Bos.
2003-02-05 18:29:34 +00:00
Jason Tishler 5c4ded2c3b Patch #551977: Regression exceptions for cygwin
Applied the skip test_ossaudiodev patch.
2003-02-05 16:46:01 +00:00
Jack Jansen cf0b2e8e28 Getting rid of macfs and FSSpecs. 2003-02-05 15:49:19 +00:00
Jack Jansen d66071b48d Got rid of macfs 2003-02-05 15:44:03 +00:00
Jack Jansen 769e1ff4a1 Fixed a few typos, and changed FSCreateResourceFile filename argument to unicode. 2003-02-05 13:39:04 +00:00
Jack Jansen b86a2e8036 Use os.path.realpath() in stead of abspath(), so the tests don't fail if
we have a symlink somewhere in the TESTFN path.
2003-02-05 11:14:16 +00:00
Raymond Hettinger 30a634e0a9 SF patch #674396: Apply UserDict.DictMixin to expand dbshelve and dbojb
to have a full dictionary interface.
2003-02-05 04:12:41 +00:00
Tim Peters 35ad641b99 Build pickler_choices list in a lazier way. 2003-02-05 04:08:07 +00:00
Tim Peters 3e667d5452 cPickle: exempt two_tuple from GC -- it's a speed hack, and doesn't
guarantee to keep valid pointers in its slots.

tests:  Moved ExtensionSaver from test_copy_reg into pickletester, and
use it both places.  Once extension codes get assigned, it won't be
safe to overwrite them willy nilly in test suites, and ExtensionSaver
does a thorough job of undoing any possible damage.

Beefed up the EXT[124] tests a bit, to check the smallest and largest
codes in each opcode's range too.
2003-02-04 21:47:44 +00:00
Tim Peters 731098b3ff cPickle now generates proto 2 EXT[124] when appropriate.
Moved such EXT tests as currently exist from TempAbstractPickleTests to
AbstractPickleTests, so that test_cpickle runs them too.
2003-02-04 20:56:09 +00:00
Walter Dörwald c3da83fcd7 Make sure filter() never returns tuple, str or unicode
subclasses. (Discussed in SF patch #665835)
2003-02-04 20:24:45 +00:00
Marc-André Lemburg 29273c87da Fix for [ 543344 ] Interpreter crashes when recoding; suggested
by Michael Stone (mbrierst).

Python 2.1.4, 2.2.2 candidate.
2003-02-04 19:35:03 +00:00
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