This gives much the same treatment to datetime.fromtimestamp(stamp, tz) as
the last batch of checkins gave to datetime.now(tz): do "the obvious"
thing with the tz argument instead of a senseless thing.
checked in two days agao:
Refactoring of, and new rules for, dt.astimezone(tz).
dt must be aware now, and tz.utcoffset() and tz.dst() must not return None.
The old dt.astimezone(None) no longer works to change an aware datetime
into a naive datetime; use dt.replace(tzinfo=None) instead.
The tzinfo base class now supplies a new fromutc(self, dt) method, and
datetime.astimezone(tz) invokes tz.fromutc(). The default implementation
of fromutc() reproduces the same results as the old astimezone()
implementation, but tzinfo subclasses can override fromutc() if the
default implementation isn't strong enough to get the correct results
in all cases (for example, this may be necessary if a tzinfo subclass
models a time zone whose "standard offset" (wrt UTC) changed in some
year(s), or in some variations of double-daylight time -- the creativity
of time zone politics can't be captured in a single default implementation).
Sebastien Keim pointed out that iterkeys and __contains__ require
their own definitions so their behavior will update when the
underlying method is subclassed.
M PyShell.py
M config-keys.def
M configHandler.py
1. Clear any un-entered characters from input line before printing the
restart boundary.
2. Restore the Debug menu: There are now both Shell and Debug menus.
3. Add Control-F6 keybinding to Restart Shell.
4. Clarify PyShell.cancel_check() comment.
5. Update doc string for Bindings.py and re-format the file slightly.
(Loewis) which uses 'SRCDIR' (if available) in package dir path.
2. Merge Python IDLE setup.py Rev 1.5 (Loewis) to allow installation
from the build directory. IDLEfork SF Patch 668998 (Loewis)
When daylight time ends, an hour repeats on the local clock (for example,
in US Eastern, the clock jumps from 1:59 back to 1:00 again). Times in
the repeated hour are ambiguous. A tzinfo subclass that wants to play
with astimezone() needs to treat times in the repeated hour as being
standard time. astimezone() previously required that such times be
treated as daylight time. There seems no killer argument either way,
but Guido wants the standard-time version, and it does seem easier the
new way to code both American (local-time based) and European (UTC-based)
switch rules, and the astimezone() implementation is simpler.
port the tests to PyUnit and add many tests for error
cases. This increases code coverage in Python/bltinmodule.c
from 75% to 92%. (From SF patch #662807, with
assert_(not fcmp(x, y)) replaced with assertAlmostEqual(x, y)
where possible)
The Py2.3 updates to the pyclbr module return both Class and Function
objects. The IDLE ClassBrowser module only knew about Class and could
not handle objects which did not define "super".
Fixed by adding a guard.
Patch from Brett Cannon:
First, the 'y' directive now handles [00, 68] as a suffix for the
21st century while [69, 99] is treated as the suffix for the 20th
century (this is for Open Group compatibility).
strptime now returns default values that make it a valid date ...
the ability to pass in a regex object to use instead of a format
string (and the inverse ability to have strptime return a regex object)
has been removed. This is in preparation for a future patch that will
add some caching internally to get a speed boost.
are going to replace StandardGetFile() and friends. Main differences are
that these allow you to ask for specific datatypes to be returned (FSSpec,
FSRef, string, unicode or subtypes thereof) and that they provide access
to underlying features of Navigation Services through keyword arguments.
underlying DB has already been closed (and thus all of its cursors).
This fixes a potential segfault.
SF pybsddb bug id 667343
bugfix: close the DB object when raising an exception due to an error
during DB.open. This prevents an exception when closing the
environment about not all databases being closed.
SF pybsddb bug id 667340
case, the test module created is actually a sub-package of 'test', thus
the module is named 'test.areallylongpackage...' - this caused failure.
Replace the hard-coded module names with __name__ attributes, which
correctly reflects any hierarchy.
M EditorWindow.py
M NEWS.txt
M config-main.def
M configDialog.py
M configHandler.py
M configHelpSourceEdit.py
M configSectionNameDialog.py
- Change default: IDLE now starts with Python Shell.
- Removed the File Path from the Additional Help Sources scrolled list.
- Add capability to access Additional Help Sources on the web if the
Help File Path begins with //http or www. (Otherwise local path is
validated, as before.)
- Additional Help Sources were not being posted on the Help menu in the
order entered. Implement sorting the list by [HelpFiles] 'option'
number.
- Add Browse button to New Help Source dialog. Arrange to start in
Python/Doc if platform is Windows, otherwise start in current directory.
- Put the Additional Help Sources directly on the Help menu instead of in
an Extra Help cascade menu. Rearrange the Help menu so the Additional
Help Sources come last. Update help.txt appropriately.
- Fix Tk root pop-ups in configSectionNameDialog.py and configDialog.py
is not supported on sets. (Unfortunately, sorting a list of sets may
still return random results because it uses < exclusively, but for
sets that inly implements a partial ordering. Oh well.)
M configHelpSourceEdit.py
1. Attach configHelpSourceEdit error dialogs to parent to avoid Tk root
pop-ups.
2. Make configHelpSourceEdit OK button the default and bind <Return>.
3. Reformat configHelpSourceEdit.
4. ConfigDialog.SaveAllChangedConfig() had a bug which caused additional
help sources to be deleted when other config items were changed.
4. Uniform capitalization in configDialog.
5. Update configDialog doc string.
hoped it would be, but not too bad. A test had to change:
time.__setstate__() can no longer add a non-None tzinfo member to a time
object that didn't already have one, since storage for a tzinfo member
doesn't exist in that case.
From:
69.73% of 294 source lines executed in file ./Modules/_codecsmodule.c
79.47% of 487 source lines executed in file Python/codecs.c
78.45% of 3643 source lines executed in file Objects/unicodeobject.c
To:
70.41% of 294 source lines executed in file ./Modules/_codecsmodule.c
82.75% of 487 source lines executed in file Python/codecs.c
80.76% of 3638 source lines executed in file Objects/unicodeobject.c
This actually unearthed a bug in the handling of None
values in PyUnicode_EncodeCharmap.
into time. This is little more than *exporting* the datetimetz object
under the name "datetime", and similarly for timetz. A good implementation
of this change requires more work, but this is fully functional if you
don't stare too hard at the internals (e.g., right now a type named
"datetime" shows up as a base class of the type named "datetime"). The
docs also need extensive revision, not part of this checkin.
- SLOT1BINFULL() macro: changed this to check for __rop__ overriding
__op__, like binary_op1() in abstract.c -- the latter only calls the
slot function once if both types use the same slot function, so the
slot function must make both calls -- which it already did for the
__op__, __rop__ order, but not yet for the __rop__, __op__ order
when B.__class__ is a subclass of A.__class__.
Also test the refinement added in rev. 2.201 that fixes the problem
reported in SF bug #623669.
Also test a similar provision in abstract.c's binary_op1().
cases, plus even tougher tests of that. This implementation follows
the correctness proof very closely, and should also be quicker (yes,
I wrote the proof before the code, and the code proves the proof <wink>).
It was once available so that faster generators could be substituted. Now,
that is less necessary and preferrably done via subclassing.
Also, clarified and shortened the comments for sample().
M Bindings.py
M EditorWindow.py
M PyShell.py
M config-keys.def
M configHandler.py
M help.txt
1. Annotate the shell window with last restart boundary upon restart.
2. Provide a shell menu entry and hot key (F6) to jump to the last
restart boundary.
3. Add a new shell menu feature to restart the shell.
4. Update the help menu to add these features.
5. Update the help menu to put text in same order as the menus.
6. Correct a capitalization inconsistency on the Edit menu: Expand Word
7. Rename the "Debug" menu to be "Shell": it's doing more now.
8. Rearrange the "Shell" menu to make the StackViewer entries adjacent.
9. Add a get_geometry method to EditorWindow, which may be of use in
making window positions persisent.
10. Make <ctrl-v> the "Classic Windows" paste key.
11. Restore decorum on the Help menu by removing "Advice". As Guido said,
things will never be the same. Thanks, David!
Lesson learned: kids should not be allowed to use API's starting
with an underscore :-/
zipimport in 2.3a1 is even more broken than I thought: I attemped
to _PyString_Resize a string created by PyString_FromStringAndSize,
which fails for strings with length 0 or 1 since the latter returns
an interned string in those cases. This would cause a SystemError
with empty source files (and no matching pyc) in the zip archive.
I rewrote the offending code to simply allocate a new buffer and
avoid _PyString_Resize altogether.
Added a test that would've caught the problem.
because the test file, msg_26.txt which has \r\n line endings, was
getting munged by cvs, which knows to do line ending conversions for
text files. But we want \r\n to be preserved on all platforms, so we
cvs admin'd the file to be -kb (binary), which means we have to open
the file in binary mode to preserve these line ends. Hopefully this
will be the end of the thrashing on this issue (but probably not).
Test passes on *nix now, and Tim confirms it passes on Windows. We'll
leave it to Jack to test MacOS.
(or None) now. In 2.3a1 they could also return an int or long, but that
was an unhelpfully redundant leftover from an earlier version wherein
they couldn't return a timedelta. TOOWTDI.
the test set as it only tested with a zip archive in the current directory,
but it doesn't work at all for packages when the zip archive was specified
as an absolute path. It's a real embarrassing bug: a strchr call should
have been strrchr; fever apparently implies dyslexia.
Second stupid bug: the zipimport test failed with a name error
__importer__ (which I had renamed to __loader__ everywhere but here).
I would've sworn I ran the test after that change but that can't be true.
What I don't understand that noone reported a failing test_zipimport.py
before the release of 2.3a1.
suggestion from Guido, along with a formal correctness proof of the
trickiest bit. The intricacy of the proof reveals how delicate this
is, but also how robust the conclusion: correctness doesn't rely on
dst() returning +- one hour (not all real time zones do!), it only
relies on:
1. That dst() returns a (any) non-zero value if and only if daylight
time is in effect.
and
2. That the tzinfo subclass implements a consistent notion of time zone.
The meaning of "consistent" was a hidden assumption, which is now an
explicit requirement in the docs. Alas, it's an unverifiable (by the
datetime implementation) requirement, but so it goes.
understood now: it can't work. Added comments explaining why (it's "the
usual"-- unrepresentable hours in local time --but in a slightly different
guise).
Remove broken code in visitDict(). I assume the code was trying to
add set lineno events for each line of a dict constructor, but I think
it was using the wrong object (node instead of k or v).
A variety of changes from Michael Hudson to get the compiler working
with 2.3. The primary change is the handling of SET_LINENO:
# The set_lineno() function and the explicit emit() calls for
# SET_LINENO below are only used to generate the line number table.
# As of Python 2.3, the interpreter does not have a SET_LINENO
# instruction. pyassem treats SET_LINENO opcodes as a special case.
A few other small changes:
- Remove unused code from pycodegen and pyassem.
- Fix error handling in parsermodule. When PyParser_SimplerParseString()
fails, it sets an exception with detailed info. The parsermodule
was clobbering that exception and replacing it was a generic
"could not parse string" exception. Keep the original exception.
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.
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().
TODO: documentation, test_modulefinder.py
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.
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.)
- 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.
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).
of the timetz case. A tzinfo method will always see a datetimetz arg,
or None, now. In the former case, it's still possible that it will get
a datetimetz argument belonging to a different timezone. That will get
fixed next.
is passed straight through to the unicode() and ustr.encode() calls.
I think it's the best we can do to address the UnicodeErrors in badly
encoded headers such as is described in SF bug #648119.
file, needed because some binary distros (read RPMs) don't include the
test module in their standard Python package. This eliminates an
external dependency and closes SF bug # 650441.
binary distros (read RPMs) don't include the test module in their
standard Python package. This eliminates an external dependency and
closes SF bug # 650441.
ignore tuple.
The line, "from _random import Random as CoreGenerator", fools the test
code which expects CoreGenerator.__name__ to be "CoreGenerator" instead
of "Random".
Guido has in mind an easier way for users to code this stuff, but the
only tests we have now are for fixed-offset tzinfo classes, and this
stuff is extremely delicate in the endcases (read the new test code
for why: there are holes in time <wink>).
M PyShell.py
1. PyShell Rev 1.39, EditorWindow Rev 1.37 fix was not handling a
multiline prompt.
2. The same fix introduced a bug where hitting <enter> at a previous
prompt-only line would copy the prompt to the iomark.
3. Move the setting of sys.ps1 earlier, into PyShell.main(), to allow
this code to work before a shell is started up.
4. If cursor is on the input line in the prompt, and you hit <enter>,
process the line instead of complaining.
5. If line has no stdin range (this includes the last line before shell
restart) strip any prompt before recalling.
equality. Note, there is another flavor that compares to a given
number of significant digits rather than decimal places. If there
is a demand, that could be added at a later date.
operands have identical tzinfo members (meaning object identity -- "is").
I misunderstood the intent here, reading wrong conclusion into
conflicting clues.
subtraction, work as documented. In the Python implementation,
they weren't calling utcoffset() if both operands had the same
tzinfo object. That's fine if it so happens that the shared
tzinfo object returns a fixed offset (independent of operand),
but can give wrong results if that's not so, and the latter
obtains in a tzinfo subclass instance trying to model both
standard and daylight times. The C implementation was already
doing this "correctly", so we're just adding tests to verify it.
module.
The code is shorter, more readable, faster, and dramatically increases the
range of acceptable dates.
Also, used the floor division operator in leapdays().
M idle
M idle.py
M idle.pyw
M setup.py
Switch back to installing IDLE as a package. The IDLE GUI and the
subprocess will both attempt to start up via the package mechanism, but if
IDLE is not yet installed it is possible to run by calling python idle.py
in the IDLE source directory, or to add the source directory to sys.path.
One advantage of doing it this way is IDLE stays off sys.path.
Developed in collaboration with Tony Lownds.
Here's a draft. I have no immediate use for it, but I'd like this to
be available for experimentation. I may withdraw it or change it
radically up to and including the release of Python 2.3b1.
M PyShell.py
M idlever.py
M setup.py
1. Update MANIFEST.in to include all non-pure Python files
2. PyShell and idlever reflect Rev 0.9a0
3. setup.py modified to install IDLE as a collection of modules with
a .pth file living at the idlelib level in site-packages. This was
done to make it easier to run from the source directory prior to
installing IDLE. This approach may change back to the package
technique depending on what happens with the Mac installation
development.
be trusted with years before 1900, so now we raise ValueError if a date or
datetime or datetimetz .strftime() method is called with a year before
1900.
{timetz,datetimetz}.{utcoffset,dst}() now return a timedelta (or None)
instead of an int (or None).
tzinfo.{utcoffset,dst)() can now return a timedelta (or an int, or None).
Curiously, this was much easier to do in the C implementation than in the
Python implementation (which lives in the Zope3 code tree) -- the C code
already had lots of hair to extract C ints from offset objects, and used
C ints internally.