bug 990669: os.path.normpath may alter the meaning of a path if it contains
symbolic links. This has been documented in a comment since 1992, but is now in
the library reference as well.
Brett Cannon [Fri, 13 Aug 2004 18:46:24 +0000 (18:46 +0000)]
'inspect' was not listing the functions in a module properly if the module was
reached through a symlink (was comparing path of module to path to function and
were not matching because of the symlink). os.path.realpath() is now used to
solve this discrepency.
Closes bug #570300. Thanks Johannes Gijsbers for the fix.
Tim Peters [Fri, 13 Aug 2004 03:55:05 +0000 (03:55 +0000)]
Doctest has new traceback gimmicks in 2.4. While trying to document
them (which they are now), I had to rewrite the code to understand
it. This has got to be the most DWIM part of doctest -- but in context
is really necessary.
Fred Drake [Fri, 13 Aug 2004 03:12:57 +0000 (03:12 +0000)]
make exception propogation more efficient; this avoids having Expat parse
the remaining data in the buffer (which it had done happily without reporting
any results)
this depends on a new feature in Expat added in 1.95.8
Tim Peters [Thu, 12 Aug 2004 18:37:10 +0000 (18:37 +0000)]
Boosted the stack reservation for python.exe and python_w.exe from the
default 1MB to 2 million bytes. The test suite passes with -uall again
(test_compiler no longer drives WinXP into an insane state).
Edward Loper [Thu, 12 Aug 2004 02:43:49 +0000 (02:43 +0000)]
In output_difference(), replace blank lines in `want` with <BLANKLINE>
(rather than replacing <BLANKLINE> with blank lines in `got`). This
makes it easier to see what's intended.
Edward Loper [Thu, 12 Aug 2004 02:41:30 +0000 (02:41 +0000)]
- Changed output of DocTestParser.get_program() to make it easier to
visually distinguish the expected output from the comments (use
"##" to mark expected outputs, and "#" to mark comments).
- If the string given to DocTestParser.get_program() is indented, then
strip its indentation. (In particular, find the min indentation of
non-blank lines, and strip that indentation from all lines.)
Edward Loper [Thu, 12 Aug 2004 02:34:27 +0000 (02:34 +0000)]
- Added __docformat__
- Added comments for some regexps
- If the traceback type/message don't match, then still print full
traceback in report_failure (not just the first & last lines)
- Renamed DocTestRunner.__failure_header -> _failure_header
Edward Loper [Thu, 12 Aug 2004 02:27:44 +0000 (02:27 +0000)]
- Changed option directives to be example-specific. (i.e., they now
modify option flags for a single example; they do not turn options
on or off.)
- Added "indent" and "options" attributes for Example
- Got rid of add_newlines param to DocTestParser._parse_example (it's
no longer needed; Example's constructor now takes care of it).
- Added some docstrings
Edward Loper [Mon, 9 Aug 2004 16:14:41 +0000 (16:14 +0000)]
- DocTest is now a simple container class; its constructor is no longer
responsible for parsing the string.
- Renamed Parser to DocTestParser
- DocTestParser.get_*() now accept the string & name as command-line
arguments; the parser's constructor is now empty.
- Added DocTestParser.get_doctest() method
- Replaced "doctest_factory" argument to DocTestFinder with a "parser"
argument (takes a DocTestParser).
- Changed _tag_msg to take an indentation string argument.
Tim Peters [Mon, 9 Aug 2004 15:43:47 +0000 (15:43 +0000)]
This started as a spelling and whitespace cleanup. The comment for
the set_trace fiddling didn't make sense to me, and I ended up reworking
that part of the code. We really do want to save and restore
pdb.set_trace, so that each dynamically nested level of doctest gets
sys.stdout fiddled to what's appropriate for *it*. The only "trick"
really needed is that these layers of set_trace wrappers each call the
original pdb.set_trace (instead of the current pdb.set_trace).
Tim Peters [Mon, 9 Aug 2004 04:34:45 +0000 (04:34 +0000)]
Removed lots of stuff from the module docstring. My intent for 2.4 is
to put details in the LaTeX docs instead, and lots of stuff in the
module docstring wasn't useful anyway.
Tim Peters [Mon, 9 Aug 2004 03:51:46 +0000 (03:51 +0000)]
Drop the excruciating newline requirements on arguments to
Example.__init__. The constructor now adds trailing newlines when
needed, and no longer distinguishes between multi- and single-line
cases for source.
Edward Loper [Mon, 9 Aug 2004 02:45:41 +0000 (02:45 +0000)]
- Split DocTestRunner's check_output and output_difference methods off
into their own class, OutputChecker.
- Added optional OutputChecker arguments to DocTestRunner,
DocTestCase, DocTestSuite.
Edward Loper [Mon, 9 Aug 2004 02:06:06 +0000 (02:06 +0000)]
Rewrote Parser, using regular expressions instead of walking though
the string one line at a time. The resulting code is (in my opinion,
anyway), much easier to read. In the process, I found and fixed a
bug in the orginal parser's line numbering in error messages (it was
inconsistant between 0-based and 1-based). Also, check for missing
blank lines after the prompt on all prompt lines, not just PS1 lines
(test added).
Tim Peters [Sun, 8 Aug 2004 16:43:59 +0000 (16:43 +0000)]
Tell unittest that source files with "badsyntax" in their names should
raise SyntaxError. test_compiler passes now on WinXP, at least in a
release-build non-O run.
Added XXX comment about why the undocumented PyRange_New() API function
is too broken to be worth the considerable pain of repairing.
Changed range_new() to stop using PyRange_New(). This fixes a variety
of bogus errors. Nothing in the core uses PyRange_New() now.
Documented that xrange() is intended to be simple and fast, and that
CPython restricts its arguments, and length of its result sequence, to
native C longs.
Added some tests that failed before the patch, and repaired a test that
relied on a bogus OverflowError getting raised.
Tim Peters [Sun, 8 Aug 2004 06:11:48 +0000 (06:11 +0000)]
Get rid of the ignore_imports argument to DocTestFinder.find().
This got slammed in when find() was fixed to stop grabbing doctests
from modules imported *by* the module being tested. Such tests cannot
be expected to succeed, since they'll be run with the current module's
globals. Dozens of Zope3 doctests were failing because of that.
It wasn't clear why ignore_imports got added then. Maybe it's because
some existing tests failed when the change was made. Whatever, it's
a Bad Idea so it's gone now.
The only use of it was exceedingly obscure, in test_doctest's "Duplicate
Removal" test. It was "needed" there because, as an artifact of running
a doctest inside a doctest, the func_globals of functions compiled in
the second-level doctest don't match the module globals, and so the
test-finder believed these functions were from a foreign module and
skipped them. But that took a long time to figure out, and I actually
understand some of this stuff <0.9 wink>.
That problem was resolved by moving the source code for the second-level
doctest into an actual module (test/doctest_aliases.py).
The only remaining difficulty was that the test for the deprecated
Tester.rundict() then failed, because the test finder doesn't take
module=None at face value, trying to guess which module the user really
intended then. Its guess wasn't appropriate for what Tester.rundict
needs when module=None is given to *it*, which is "no, there is no
module here, and I mean it". So now passing module=False means exactly
that. This is hokey, but ignore_imports=False was really a hack to worm
around that there was no way to tell the test-finder that module=None
*sometimes* means what it says. There was no use case for the combination
of passing a real module with ignore_imports=False.
Tim Peters [Sun, 8 Aug 2004 01:48:59 +0000 (01:48 +0000)]
Deprecated testmod's useless & confusing isprivate gimmick.
Ripped out the docs for the new DocTestFinder's namefilter argument,
and renamed it to _namefilter; this only existed to support isprivate.
Removed the new DocTestFinder's objfilter argument. No point adding
more cruft to a broken filtering design.
Tim Peters [Sun, 8 Aug 2004 01:00:47 +0000 (01:00 +0000)]
Bug 1003471: Python 1.5.2 security vulnerability still present in 2.3.4
That's the title of the report, but the hole was probably plugged since
Python 2.0. See corresponding checkin to PC/getpathp.c: a crucial
precondition for joinpath() was neither documented nor verified, and there
are so many callers with so many conditional paths that no "eyeball
analysis" is satisfactory. Now Python dies with a fatal error if the
precondition isn't satisfied, instead of allowing a buffer overrun.
NOT TESTED! The Windows version of the patch was, but not this one. I
don't feel like waiting for someone to notice the patch I attached to the
bug report. If it doesn't compile, sorry, but fix it <wink>. If it
does compile, it's "obviously correct".
Armin Rigo [Sat, 7 Aug 2004 20:58:32 +0000 (20:58 +0000)]
This was quite a dark bug in my recent in-place string concatenation
hack: it would resize *interned* strings in-place! This occurred because
their reference counts do not have their expected value -- stringobject.c
hacks them. Mea culpa.
Armin Rigo [Sat, 7 Aug 2004 20:30:03 +0000 (20:30 +0000)]
Removing tests that fail because of changes in PyString_InternInPlace(),
as discussed on IRC. The equivalent tests for the new behavior are in
test_builtin.py.
[Patch #1003861 from Dima Dorfman] Fix markup in concrete.tex:
PyObject* o -> PyObject *o to be consistent with the
rest of the file
- Correct markup for Py_True
- Remove duplicate description of PyBool_Check
[Bug #914375] Crude modulefinder docs, but the module's code is very hard to read and it's not clear which bits are public and which aren't. The module's author should really be doing this (and using docstrings in the code, too)