pydoc now supports PEP 302 importers, by way of utility functions in
pkgutil, such as 'walk_packages()'. It will properly document
modules that are in zip files, and is backward compatible to Python
2.3 (setuptools installs for Python <2.5 will bundle it so pydoc
doesn't break when used with eggs.)
What has not changed is that pydoc command line options do not support
zip paths or other importer paths, and the webserver index does not
support sys.meta_path. Those are probably okay as limitations.
Tasks remaining: write docs and Misc/NEWS for pkgutil/pydoc changes,
and update setuptools to use pkgutil wherever possible, then add it
to the stdlib.
C++ compilation cleanup: Migrate declaration of
_PyObject_Call(Function|Method)_SizeT into Include/abstract.h. This gets
them under the umbrella of the extern "C" { ... } block in that file.
Tim Peters [Mon, 17 Apr 2006 21:12:33 +0000 (21:12 +0000)]
local.__del__(): This didn't actually do anything, because of too
much convolution <0.5 wink>. Simplified to the point that it works,
and test_threading_local no longer reports leaks under -R. Thanks
to Thomas Wouters for initial analysis.
This revision strips all the PEP 302 emulation code from runpy,
replacing it with published API classes and functions in pkgutil,
mostly using setuptools' implementation of common functionality,
but adding features from runpy, and doing some refactoring to make
the layer pydoc needs easier to implement on top of this.
One step down, four to go, although step #4 (adding C versions of
the new APIs to 'imp') may not be able to make it in time for
alpha 2. We'll see how that goes.
Ronald Oussoren [Mon, 17 Apr 2006 14:43:30 +0000 (14:43 +0000)]
disutils checks if MACOSX_DEPLOYMENT_TARGET is consistent with the value at
configure time. The current check is too strict and doesn't allow building
extensions that can only run on newer versions of the OS than the version
python was build for, that is python build for 10.3 or later and an extension
for 10.4. This patch relaxes this check.
This turned out to be a reimplementation of patch 1193190.
now failed with pyconfig.h not found. Prior to r45232
the above command did not look for pyconfig.h, but the
bug is really in the look-up code: expecting to find it
in os.curdir is a rather fragile idea.
Write most of the 'writing context managers' section. I'd like comments on it,
but wait for a few hours before you read it; I'm still revising it
and will be tackling contextlib next.
Untabify
Thomas Wouters [Sun, 16 Apr 2006 15:43:39 +0000 (15:43 +0000)]
Make test_warnings play nice with regrtest -R:: now that regrtest doesn't
always reload the module (specifically, it doesn't reload if the module has
a 'test_main'.)
Thomas Wouters [Sun, 16 Apr 2006 15:22:41 +0000 (15:22 +0000)]
Specialcase 'xs4all' (.nl/.net/.com/whatever else we have) as well as
'python.org' when deciding what server to use for the timeout tests; getting
tired of seeing the test fail on all my boxes ;P This'll still allow the
test to fail for hosts in the XS4ALL network that don't have an 'xs4all'
hostname, so maybe it should use a fallback scheme instead.
Thomas Wouters [Sat, 15 Apr 2006 23:27:28 +0000 (23:27 +0000)]
Add missing DECREF to PyErr_WriteUnraisable(). That function reports
exceptions that can't be raised any further, because (for instance) they
occur in __del__ methods. The coroutine tests in test_generators was
triggering this leak. Remove the leakers' testcase, and add a simpler
testcase that explicitly tests this leak to test_generators.
test_generators now no longer leaks at all, on my machine. This fix may also
solve other leaks, but my full refleakhunting run is still busy, so who
knows?
Tim Peters [Sat, 15 Apr 2006 22:59:10 +0000 (22:59 +0000)]
gen_del(): Looks like much this was copy/pasted from
slot_tp_del(), but while the latter had to cater to types
that don't participate in GC, we know that generators do.
That allows strengthing an assert().
Thomas Wouters [Sat, 15 Apr 2006 22:33:13 +0000 (22:33 +0000)]
Add missing PyObject_GC_Track call, causing *some* itertools.tee objects to
not be tracked by GC. This fixes 254 of test_generators' refleaks on my
machine, but I'm sure something else will make them come back :>
Not adding a separate test for this kind of cycle, since the existing
fib/m235 already test them in more extensive ways than any 'minimal' test
has been able to manage.
Thomas Wouters [Sat, 15 Apr 2006 21:47:09 +0000 (21:47 +0000)]
Use Py_VISIT in all tp_traverse methods, instead of traversing manually or
using a custom, nearly-identical macro. This probably changes how some of
these functions are compiled, which may result in fractionally slower (or
faster) execution. Considering the nature of traversal, visiting much of the
address space in unpredictable patterns, I'd argue the code readability and
maintainability is well worth it ;P
Thomas Wouters [Sat, 15 Apr 2006 21:41:56 +0000 (21:41 +0000)]
- Whitespace normalization
- In functions where we already hold the same object in differently typed
pointers, use the correctly typed pointer instead of casting the other
pointer a second time.
Martin v. Löwis [Sat, 15 Apr 2006 12:45:05 +0000 (12:45 +0000)]
Unlink the structseq type from the global list of
objects before initializing it. It might be linked
already if there was a Py_Initialize/Py_Finalize
cycle earlier; not unlinking it would break the global
list.
Tim Peters [Sat, 15 Apr 2006 03:22:46 +0000 (03:22 +0000)]
frame_traverse(): Use the standard Py_VISIT macro.
Py_VISIT: cast the `op` argument to PyObject* when calling
`visit()`. Else the caller has to pay too much attention to
this silly detail (e.g., frame_traverse needs to traverse
`struct _frame *` and `PyCodeObject *` pointers too).
Tim Peters [Sat, 15 Apr 2006 01:48:57 +0000 (01:48 +0000)]
Changed comments to make sense now that the LazyList-based
examples no longer require any explicit closing to avoid
leaking.
That the tee-based examples still do is (I think) still a
mystery. Part of the mystery is that gc.garbage remains
empty: if it were the case that some generator in a trash
cycle said it needed finalization, suppressing collection
of that cycle, that generator _would_ show up in gc.garbage.
So this is acting more like, e.g., some tp_traverse slot
isn't visiting all the pointers it should (in which case
the skipped pointer(s) would act like an external root,
silently suppressing collection of everything reachable
from it(them)).
Fix SF#1470508: crash in generator cycle finalization. There were two
problems: first, PyGen_NeedsFinalizing() had an off-by-one bug that
prevented it from ever saying a generator didn't need finalizing, and
second, frame objects cleared themselves in a way that caused their
owning generator to think they were still executable, causing a double
deallocation of objects on the value stack if there was still a loop
on the block stack. This revision also removes some unnecessary
close() operations from test_generators that are now appropriately
handled by the cycle collector.
Thomas Wouters [Fri, 14 Apr 2006 21:23:42 +0000 (21:23 +0000)]
Coverity-found bug: datetime_strptime() failed to check for NULL return from
PySequence_GetItem of the time.strptime() result. Not a high probability
bug, but not inconceivable either, considering people can provide their own
'time' module.
Walter Dörwald [Fri, 14 Apr 2006 18:25:39 +0000 (18:25 +0000)]
Add a BufferedIncrementalEncoder class that can be used for implementing
an incremental encoder that must retain part of the data between calls
to the encode() method.
Fix the incremental encoder and decoder for the IDNA encoding.