Tim Peters [Tue, 31 Dec 2002 17:36:56 +0000 (17:36 +0000)]
A new, and much hairier, implementation of astimezone(), building on
an idea from Guido. This restores that the datetime implementation
never passes a datetime d to a tzinfo method unless d.tzinfo is the
tzinfo instance whose method is being called. That in turn allows
enormous simplifications in user-written tzinfo classes (see the Python
sandbox US.py and EU.py for fully fleshed-out examples).
d.astimezone(tz) also raises ValueError now if d lands in the one hour
of the year that can't be expressed in tz (this can happen iff tz models
both standard and daylight time). That it used to return a nonsense
result always ate at me, and it turned out that it seemed impossible to
force a consistent nonsense result under the new implementation (which
doesn't know anything about how tzinfo classes implement their methods --
it can only infer properties indirectly). Guido doesn't like this --
expect it to change.
New tests of conversion between adjacent DST-aware timezones don't pass
yet, and are commented out.
Running the datetime tests in a loop under a debug build leaks 9
references per test run, but I don't believe the datetime code is the
cause (it didn't leak the last time I changed the C code, and the leak
is the same if I disable all the tests that invoke the only function
that changed here). I'll pursue that next.
Fred Drake [Tue, 31 Dec 2002 17:23:27 +0000 (17:23 +0000)]
Further cleanup of exceptions. All interpolation-related exceptions
now derive from InterpolationError, which is not raised directly (only
subclasses get raised). This matches what the docs already said.
Skip Montanaro [Tue, 31 Dec 2002 16:56:20 +0000 (16:56 +0000)]
Bernhard Herzog's paragraph and string-filling code. I've been using it for
a month or two with great success. Barry may want to tweak it some, but I
think it's a worthwhile enough addition to get some more people trying it
out.
Guido van Rossum [Tue, 31 Dec 2002 16:33:01 +0000 (16:33 +0000)]
Fix an out-of-bound index in pmerge() discovered by Zooko (SF bug
645404). I'm not 100% sure this is the right fix, so I'll keep the
bug report open for Samuele, but this fixes the index error and passes
the test suite (and I can't see why it *shouldn't* be the right fix
:-).
Just van Rossum [Tue, 31 Dec 2002 16:33:00 +0000 (16:33 +0000)]
patch attached to sf item #643711:
any_missing() returns less bogus missing modules.
- I've rewritten scan_code() more or less from scratch,
factored bits and pieces out for readability.
- keep track of global assignments and failed imports per
module; use this to determine whether the Y in "from X
import Y" is a submodule or just a global name. This is not
100% doable: you can't tell which symbols are imported when
doing a star import of a non-Python module short of actually
importing it.
- added a new method to ModuleFinder: any_missing_maybe(),
which returns *two* lists, one with certain misses, one with
possible misses. The possible misses are *very* often false
alarms, so it's useful to keep this list separate.
any_misses() now simply returns the union of
any_missing_maybe().
Tim Peters [Tue, 31 Dec 2002 16:01:47 +0000 (16:01 +0000)]
Removed the now-untrue (or soon-to-be untrue) part of the astimezone()
docs. Replaced it with an XXX block, because the hoped-for treatment
of DST endcases remains unclear (Guido doesn't really like raising an
exception when it's impossible to deliver a correct result, but so
far I have no way in hand to consistently deliver a defined incorrect
result either).
Andrew MacIntyre [Tue, 31 Dec 2002 11:18:08 +0000 (11:18 +0000)]
Build process updates:
- add new modules (zipimport, datetime, _random, bz2, _symtable)
- build pyexpat with expat sources from Python distribution
- regression test with and without compiled bytecode
Fred Drake [Tue, 31 Dec 2002 07:16:16 +0000 (07:16 +0000)]
Make sure PrettyPrinter methods that mirror the module-level
convenience functions isreadable() and isrecursive() work the same way
as the convenience functions.
Fred Drake [Tue, 31 Dec 2002 07:14:18 +0000 (07:14 +0000)]
- PrettyPrinter.isreadable(), .isrecursive():
Pass the right number of args to .format(). (Caught by
pychecker.)
- Protect the global namespace more carefully.
- Don't use the types module now that we don't need to.
Fred Drake [Tue, 31 Dec 2002 06:57:25 +0000 (06:57 +0000)]
Add a test that InterpolationError is constructed properly and raised
when expected. Only applies to the ConfigParser and SafeConfigParser
classes, not RawConfigParser.
Fred Drake [Tue, 31 Dec 2002 06:55:41 +0000 (06:55 +0000)]
ConfigParser._interpolate(): Pass the missing key to the
InterpolationError constructor, not the KeyError exception itself.
(Caught by the new InterpolationError test.)
SafeConfigParser._interpolate_some(): Pass the right number of
arguments to the InterpolationError constructor.
(Caught by pychecker.)
Neal Norwitz [Tue, 31 Dec 2002 00:06:24 +0000 (00:06 +0000)]
Fix SF #639945, 64-bit bug on AIX
I can't test this on the snake farm (no aix box is working).
This change works for the submitter seems correct.
Can anybody test this on 32- and 64- bit AIX?
Fred Drake [Mon, 30 Dec 2002 23:32:50 +0000 (23:32 +0000)]
- prefer "import ... as" to "import / (assignments) / del" for most things
- when the thread module isn't available, subsequent attempts to import
threading should not suceed
Guido van Rossum [Mon, 30 Dec 2002 22:36:09 +0000 (22:36 +0000)]
Use the dummy_thread module in Queue.py and tempfile.py.
tempfile.py already contained code to let it run without threads present;
for Queue.py this is considered a useful feature too.
Neal Norwitz [Mon, 30 Dec 2002 22:29:22 +0000 (22:29 +0000)]
SF #561244, Micro optimizations
Initialize the small integers and __builtins__ in startup.
This removes some if conditions.
Change XDECREF to DECREF for values which shouldn't be NULL.
Jack Jansen [Mon, 30 Dec 2002 22:23:40 +0000 (22:23 +0000)]
Adapted for the move of Mac/Lib to Lib/plat-mac. Makefile.pre.in now
knows about plat-mac subdirectories, and configure adds a variable
EXTRAPLATDIR. These together take care of copying Lib/plat-mac to
the destination on darwin.
Adding plat-mac is still done with a .pth file which is only created when
you do a framework build. I'm not 100% happy with this, but fixing it
really needs a functional pythonw in non-framework builds, and I don't
think I can do that before 2.3a1 (but I'll try:-).
Just van Rossum [Mon, 30 Dec 2002 22:08:05 +0000 (22:08 +0000)]
PEP 302 + zipimport:
- new import hooks in import.c, exposed in the sys module
- new module called 'zipimport'
- various changes to allow bootstrapping from zip files
I hope I didn't break the Windows build (or anything else for that
matter), but then again, it's been sitting on sf long enough...
Regarding the latest discussions on python-dev: zipimport sets
pkg.__path__ as specified in PEP 273, and likewise, sys.path item such as
/path/to/Archive.zip/subdir/ are supported again.
Jack Jansen [Mon, 30 Dec 2002 22:04:23 +0000 (22:04 +0000)]
Moved most of Mac/Lib hierarchy to Lib/plat-mac: it can be used both
in MacPython-OS9 and MacPython-OSX (or the equivalent unix Python on
Mac OS X). The only items remaining in Mac/Lib are modules that are
meaningful only for MacPython-OS9 (CFM stuff, MacPython preferences
in resources, etc).
Tim Peters [Mon, 30 Dec 2002 21:28:52 +0000 (21:28 +0000)]
Bite the bullet on all the indirect timetz and datetimetz tzinfo methods:
make the callers figure out the right tzinfo arguments to pass, instead of
making the callees guess. The code is uglier this way, but it's less
brittle (when the callee guesses, the caller can get surprised).