Tim Peters [Sat, 8 Feb 2003 03:46:31 +0000 (03:46 +0000)]
The Python implementation of datetime was changed in ways that no longer
tickle the 2.2.2 __cmp__ bug test_datetime used to tickle, so the
workarounds for that bug no longer make sense in the test suite (which I'm
still trying to keep as closely in synch as possible with Zope3's
version).
Tim Peters [Fri, 7 Feb 2003 22:50:28 +0000 (22:50 +0000)]
Comparison for timedelta, time, date and datetime objects: __eq__ and
__ne__ no longer complain if they don't know how to compare to the other
thing. If no meaningful way to compare is known, saying "not equal" is
sensible. This allows things like
if adatetime in some_sequence:
and
somedict[adatetime] = whatever
to work as expected even if some_sequence contains non-datetime objects,
or somedict non-datetime keys, because they only call __eq__.
It still complains (raises TypeError) for mixed-type comparisons in
contexts that require a total ordering, such as list.sort(), use as a
key in a BTree-based data structure, and cmp().
Somehow, copy() of a classic class object was handled
atomically, but deepcopy() didn't support this at all.
I don't see any reason for this, so I'm adding ClassType
to the set of types that are deep-copied atomically.
Jack Jansen [Fri, 7 Feb 2003 15:45:40 +0000 (15:45 +0000)]
Made AskFile* dialogs movable-modal by default, by providing a dummy
eventProc (which simply drops all events on the floor). Also added a
method SetDefaultEventProc through which frameworks can set a global
event handler (which can still be overridden on a per-call basis
with the eventProc argument).
* Eliminated tuple re-use in imap(). Doing it correctly made the code
too hard to read.
* Simplified previous changes to izip() to make it easier to read.
* Fixed typo in exception message for times()
* Filled in missing times_traverse()
* Document reasons that imap() did not adopt a None fill-in feature
* Document that count(sys.maxint) will wrap-around on overflow
* Add overflow test to islice()
* Check that starmap()'s argument returns a tuple
* Verify that imap()'s tuple re-use is safe
* Make a similar tuple re-use (with safety check) for izip()
Tim Peters [Fri, 7 Feb 2003 01:53:46 +0000 (01:53 +0000)]
SF bug 666444: 'help' makes linefeed only under Win32.
Reverting one of those irritating "security fixes". fdopen() opens
files in binary mode. That makes pydoc skip the \r\n on Windows that's
need to make the output readable in the shell. Screw it.
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.
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?
Tim Peters [Thu, 6 Feb 2003 16:42:14 +0000 (16:42 +0000)]
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.
Anthony Baxter [Thu, 6 Feb 2003 01:45:11 +0000 (01:45 +0000)]
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.
Jeremy Hylton [Wed, 5 Feb 2003 23:13:00 +0000 (23:13 +0000)]
Small function call optimization and special build option for call stats.
-DCALL_PROFILE: Count the number of function calls executed.
When this symbol is defined, the ceval mainloop and helper functions
count the number of function calls made. It keeps detailed statistics
about what kind of object was called and whether the call hit any of
the special fast paths in the code.
Optimization:
When we take the fast_function() path, which seems to be taken for
most function calls, and there is minimal frame setup to do, avoid
call PyEval_EvalCodeEx(). The eval code ex function does a lot of
work to handle keywords args and star args, free variables,
generators, etc. The inlined version simply allocates the frame and
copies the arguments values into the frame.
The optimization gets a little help from compile.c which adds a
CO_NOFREE flag to code objects that don't have free variables or cell
variables. This change allows fast_function() to get into the fast
path with fewer tests.
I measure a couple of percent speedup in pystone with this change, but
there's surely more that can be done.
Jeremy Hylton [Wed, 5 Feb 2003 22:39:29 +0000 (22:39 +0000)]
Refactor the logic for setting f_builtins.
For the case where the current globals match the previous frame's
globals, eliminates three tests in two if statements. For the case
where we just get __builtins__ from a module, eliminate a couple of
tests.
[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.
Tim Peters [Wed, 5 Feb 2003 19:55:53 +0000 (19:55 +0000)]
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.
Jason Tishler [Wed, 5 Feb 2003 15:16:17 +0000 (15:16 +0000)]
This patch reverts the following:
It also prevents building against the real X headers, if installed.
After discussions with the Cygwin project lead, I believe that building
against the real X headers is OK. Especially, since the psuedo-X headers
are *not* installed by the Cygwin Tcl/Tk binary package.
Jason Tishler [Wed, 5 Feb 2003 15:06:46 +0000 (15:06 +0000)]
This patch enables Cygwin Python to build _tkinter against Tcl/Tk 8.4.
Note that this patch just reverts the lib_prefix (i.e., "cyg") portion
of my Tcl/Tk 8.3 patch. It seems that Cygwin Tcl/Tk is using a more
normal file naming convention again.
Tim Peters [Tue, 4 Feb 2003 21:47:44 +0000 (21:47 +0000)]
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.
Tim Peters [Tue, 4 Feb 2003 20:56:09 +0000 (20:56 +0000)]
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.
Walter Dörwald [Tue, 4 Feb 2003 16:28:00 +0000 (16:28 +0000)]
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.
Jack Jansen [Tue, 4 Feb 2003 15:36:42 +0000 (15:36 +0000)]
- 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.
Fred Drake [Tue, 4 Feb 2003 15:12:06 +0000 (15:12 +0000)]
Update to better reflect the usage of struct_time instances throughout;
continuing to call these "time tuples" is misleading at best.
Closes SF bug #671731; will backport to 2.2.x.
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.
Tim Peters [Tue, 4 Feb 2003 00:21:07 +0000 (00:21 +0000)]
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].