ZipFile.__del__(): call ZipFile.close(), like its docstring says it does.
ZipFile.close(): allow calling more than once (as all file-like objects
in Python should support).
More changes to the formatdate epoch test: the Mac epoch is in
localtime, so east of GMT it falls in 1903:-( Changed the test to
obtain the epoch in both local time and GMT, and do the right
thing in the comparisons. As a sanity measure also check that
day/month is Jan 1.
_verify(): Pass in the values of globals insted of eval()ing their
names. The use of eval() was obscure and unnecessary, and the patch
claimed random.py couldn't be used in Jython applets because of it.
- Fix for SF bug #482752: __getstate__ & __setstate__ ignored (by Anon.)
In fact, only __getstate__ isn't recognized. This fixes that.
- Separately, the test for base.__flags__ & _HEAPTYPE raised an
AttributeError exception when a classic class was amongst the
bases. Fixed this with a hasattr() bandaid (classic classes never
qualify as the "hard" base class anyway, which is what the code is
trying to find).
use the correct way to test for epoch, by looking at the year
component of gmtime(0). Add clause for Unix epoch and Mac epoch (Tim,
what is Windows epoch?).
Also, get rid of the strptime() test, it was way too problematic given
that strptime() is missing on many platforms and issues with locales.
Instead, simply test that formatdate() gets the numeric timezone
calculation correct for the altzone and timezone.
incorrect for "uneven" timezones. This algorithm should work for even
timezones (e.g. America/New_York) and uneven timezones (e.g.
Australia/Adelaide and America/St_Johns).
Closes SF bug #483231.
split parameters from the last path segment. Introduces two new functions,
urlsplit() and urlunsplit(), that do the simpler job of splitting the URL
without monkeying around with the parameters field, since that was not being
handled properly.
This closes bug #478038.
load_inst(): Implement the security hook that cPickle already had.
When unpickling callables which are not classes, we look to see if the
object has an attribute __safe_for_unpickling__. If this exists and
has a true value, then we can call it to create the unpickled object.
Otherwise we raise an UnpicklingError.
find_class(): We no longer mask ImportError, KeyError, and
AttributeError by transforming them into SystemError. The latter is
definitely not the right thing to do, so we let the former three
exceptions simply propagate up if they occur, i.e. we remove the
try/except!
of multiple inheritance from a mix of new- and classic-style classes.
This is his patch, plus a start at some test cases from me. Will check
in more, plus a NEWS blurb, later tonight.
This gives mmap() on Windows the ability to create read-only, write-
through and copy-on-write mmaps. A new keyword argument is introduced
because the mmap() signatures diverged between Windows and Unix, so
while they (now) both support this functionality, there wasn't a way to
spell it in a common way without introducing a new spelling gimmick.
The old spellings are still accepted, so there isn't a backward-
compatibility issue here.
message for bad mode argument -- so that it doesn't fail on Windows.
It's hack. We know that errno is set to 0 in this case on Windows, so
check for that specifically.
rfc822.py. The old rfc822.formatdate() produced date strings using
obsolete syntax. The new version produces the preferred RFC 2822
dates.
Also, an optional argument `localtime' is added, which if true,
produces a date relative to the local timezone, with daylight savings
time properly taken into account.
Fix contributed by Jeffrey C. Ollie.
I haven't tested the fix because the situation is non-trivial to
reproduce.
The basic solution is to get rid of the __current_realm attribute of
authentication handlers. Instead, prevent infinite retries by
checking for the presence of an Authenticate: header in the request
object that exactly matches the Authenticate: header that would be
added.
The problem prevent authentication from working correctly in the
presence of retries.
Ollie mentioned that digest authentication has the same problem and I
applied the same solution there.
Fix by Neil Schemenauer. Visit the Subscript node when trying to find
the operation for a statement.
XXX Not sure if there are other nodes that should be visited.
ntpath.join('a', '') was producing 'a' instead of 'a\\' as in 2.1.
Impossible to guess what was ever *intended*, but since split('a\\')
produces ('a', ''), I think it's best if join('a', '') gives 'a\\' back.
__getaddr(): Watch out for empty addresses that can happen when
something like "MAIL FROM:<CR>" is received. This avoids the
IndexError and rightly returns an SMTP syntax error.
parseargs(): We didn't handle the 2-arg case where both the localspec
and the remotespec were provided on the command line.
and NEWS. Bugfix candidate? That's a dilemma for Anthony <wink>: /F
did fix a longstanding bug here, but the fix can cause code to raise an
exception that previously worked by accident.
test_commands does not work on IRIX
It assumes the output of "ls /bin/ls" is a line
that starts with a '-'. On IRIX that file is
a symbolic link, so the first character is an l.
This causes test_getstatus to fail.
dictionary instead of building a new one, and provide an overridable method
to allow subclasses to catch ADD_INFO records that are not part of the
initial block of ADD_INFO records created by the profiler itself.
And SF patch 473223 -- infinite getattr loop
Wrap select() and poll() calls with try/except for EINTR. If EINTR is
raised, treat as a response where no fd is ready.
In dispatcher constructor, make sure self.socket is always
initialized.
outer level, the iterator protocol is used for memory-efficiency (the
outer sequence may be very large if fully materialized); at the inner
level, PySequence_Fast() is used for time-efficiency (these should
always be sequences of length 2).
dictobject.c, new functions PyDict_{Merge,Update}FromSeq2. These are
wholly analogous to PyDict_{Merge,Update}, but process a sequence-of-2-
sequences argument instead of a mapping object. For now, I left these
functions file static, so no corresponding doc changes. It's tempting
to change dict.update() to allow a sequence-of-2-seqs argument too.
Also changed the name of dictionary's keyword argument from "mapping"
to "x". Got a better name? "mapping_or_sequence_of_pairs" isn't
attractive, although more so than "mosop" <wink>.
abstract.h, abstract.tex: Added new PySequence_Fast_GET_SIZE function,
much faster than going thru the all-purpose PySequence_Size.
libfuncs.tex:
- Document dictionary().
- Fiddle tuple() and list() to admit that their argument is optional.
- The long-winded repetitions of "a sequence, a container that supports
iteration, or an iterator object" is getting to be a PITA. Many
months ago I suggested factoring this out into "iterable object",
where the definition of that could include being explicit about
generators too (as is, I'm not sure a reader outside of PythonLabs
could guess that "an iterator object" includes a generator call).
- Please check my curly braces -- I'm going blind <0.9 wink>.
abstract.c, PySequence_Tuple(): When PyObject_GetIter() fails, leave
its error msg alone now (the msg it produces has improved since
PySequence_Tuple was generalized to accept iterable objects, and
PySequence_Tuple was also stomping on the msg in cases it shouldn't
have even before PyObject_GetIter grew a better msg).
the separating semi-colon shows up on a continuation line (legal, but
weird).
Bug reported and fixed by Matthew Cowles. Test case and sample email
included.
non-standard but common types. Including Martin's suggestion to add
rejected non-standard types from patch #438790. Specifically,
guess_type(), guess_extension(): Both the functions and the methods
grow an optional "strict" flag, defaulting to true, which determines
whether to recognize non-standard, but commonly found types or not.
Also, I sorted, reformatted, and culled duplicates from the big
types_map dictionary. Note that there are a few non-equivalent
duplicates (e.g. .cdf and .xls) for which the first will just get
thrown away. I didn't remove those though.
Finally, use of the module as a script as grown the -l and -e options
to toggle strictness and to do guess_extension(), respectively.
Doc and unittest updates too.
As the comments in the module implied, pyclbr was easily confused by
"strange stuff" inside single- (but not triple-) quoted strings. It
isn't anymore. Its behavior remains flaky in the presence of nested
functions and classes, though.
Bugfix candidate.
ThreadingMixIn/TCPServer forgets close (Max Neunhöffer).
This ensures that handle_error() and close_request() are called when
an error occurs in the thread.
(I am not applying the second chunk of the patch, which moved the
finish() call into the finally clause in BaseRequestHandler's __init__
method; that would be a semantic change that I cannot accept at this
point - the data would be sent even if the handler raised an
exception.)
used by the weakref code since he didn't like the word "referencable".
Is it really necessary to be more specific than to test for TypeError here,
though?
There really isn't a good reason for instance method objects to have
their own __dict__, __doc__ and __name__ properties that just delegate
the request to the function (callable); the default attribute behavior
already does this.
The test suite had to be fixed because the error changes from
TypeError to AttributeError.
strings, not C strings)
removed USE_PYTHON defines, and related sre.py helpers
skip calling the subx helper if the template is callable.
interestingly enough, this means that
def callback(m):
return literal
result = pattern.sub(callback, string)
is much faster than
result = pattern.sub(literal, string)
removed (conceptually flawed) getliteral helper; the new sub/subn code
uses a faster code path for literal replacement strings, but doesn't
(yet) look for literal patterns.
added STATE_OFFSET macro, and use it to convert state.start/ptr to
char indexes
_handle_multipart(): If there is an epilogue and the epilogue does
not itself start with a newline, add a newline before writing the
epilogue. Closes SF bug #472481.
This adds unsetenv to posix, and uses it in the __delitem__ method of
os.environ.
(XXX Should we change the preferred name for putenv to setenv, for
consistency?)
This is a big one, touching lots of files. Some of the platforms
aren't tested yet. Briefly, this changes the return value of the
os/posix functions stat(), fstat(), statvfs(), fstatvfs(), and the
time functions localtime(), gmtime(), and strptime() from tuples into
pseudo-sequences. When accessed as a sequence, they behave exactly as
before. But they also have attributes like st_mtime or tm_year. The
stat return value, moreover, has a few platform-specific attributes
that are not available through the sequence interface (because
everybody expects the sequence to have a fixed length, these couldn't
be added there). If your platform's struct stat doesn't define
st_blksize, st_blocks or st_rdev, they won't be accessible from Python
either.
(Still missing is a documentation update.)
The GUI-mode code to display properties blew up if the property functions
(get, set, etc) weren't simply methods (or functions).
"The problem" here is really that the generic document() method dispatches
to one of .doc{routine, class, module, other}(), but all of those require
a different(!) number of arguments. Thus document isn't general-purpose
at all: you have to know exactly what kind of thing is it you're going
to document first, in order to pass the correct number of arguments to
.document for it to pass on. As an expedient hack, just tacked "*ignored"
on to the end of the formal argument lists for the .docXXX routines so
that .document's caller doesn't have to know in advance which path
.document is going to take.