Tim Peters [Thu, 23 Sep 2004 02:39:37 +0000 (02:39 +0000)]
A static swapped_op[] array was defined in 3 different C files, & I think
I need to define it again. Bite the bullet and define it once as an
extern, _Py_SwappedOp[].
Edward Loper [Tue, 21 Sep 2004 03:00:51 +0000 (03:00 +0000)]
- Updated docs to reflect changes in 2.4.
- Reorganized the documentation
- Shifted focus a little more towards "literate testing"
- Documented new functions and classes:
- testfile()
- Example, DocTest
- DocTestParser, DocTestFinder, DocTestRunner, OutputChecker
- DocFileSuite
- DebugRunner, DocTestFailure, UnexpectedException
- register_optionflag()
Sort classes by fully qualified name. In the common case where you are
displaying a set of classes from one module it doesn't matter, but if you
are displaying a large class tree from multiple modules it improves the
display to sort by module.name.
Edward Loper [Sun, 19 Sep 2004 17:19:33 +0000 (17:19 +0000)]
- Added "testfile" function, a simple function for running & verifying
all examples in a given text file. (analagous to "testmod")
- Minor docstring fixes.
- Added module_relative parameter to DocTestFile/DocTestSuite, which
controls whether paths are module-relative & os-independent, or
os-specific.
SF bug #1030557: PyMapping_Check crashes when argument is NULL
Make PySequence_Check() and PyMapping_Check() handle NULL inputs. This
goes beyond what most of the other checks do, but it is nice defensive
programming and solves the OP's problem.
When this file is sourced in, or used as, one's vimrc file it will set the proper settings to follow the style guidelines laid out in PEPs 7 & 8 as best it can without forcing extraneous settings.
Suggested settings are commented out and included at the end of the file.
The goal is to have this file prevent as much as possible from deviating from the style guidelines. It is not meant to collect every cool macro possible for Python. Any useful settings for features included with Vim can be included and commented out, but anything overly extraneous should be left out.
Edward Loper [Sun, 19 Sep 2004 01:16:44 +0000 (01:16 +0000)]
- Updated example output to match actual output
- Minor wording changes
- Changed the docs to reflect the fact that multiple option directives
can be specified on a single line (and updated the directive
production list, as well).
Edward Loper [Sat, 18 Sep 2004 20:27:04 +0000 (20:27 +0000)]
In DocFileTest:
- Fixed bug in handling of absolute paths.
- If run from an interactive session, make paths relative to the
directory containing sys.argv[0] (since __main__ doesn't have
a __file__ attribute).
Barry Warsaw [Sat, 18 Sep 2004 00:06:34 +0000 (00:06 +0000)]
At the cost of a modest (but useful in its own right) change in the semantics
of the Template.delimiter attribute, we make use of the delimiter in the
escaped group, and in the safe_substitute() method more robust.
Now, .delimiter should be the unescaped delimiter literal, e.g. '$' or '&', or
whatever. The _TemplateMetaclass will re.escape() this value when it builds
the pattern.
High level error message was stomping useful detailed messages from lower
level routines.
The new approach is to augment string error messages returned by the low
level routines. The provides both high and low level information. If
the exception value is not a string, no changes are made.
To see the improved messages in action, type:
import random
class R(random): pass
class B(bool): pass
Make the word "module" appear in the error string for calling the
module type with silly arguments. (The exact name can be quibbled
over, if you care).
This was partially inspired by bug #1014215 and so on, but is also
just a good idea.
Walter Dörwald [Tue, 14 Sep 2004 09:40:45 +0000 (09:40 +0000)]
Enhance the docstrings for unicode.split() and string.split()
to make it clear that it is possible to pass None as the
separator argument to get the default "any whitespace" separator.
* The parameterization of "delimiter" was incomplete.
* safe_substitute's code for braced delimiters should only be executed
when braced is not None.
* Invalid pattern group names now raise a ValueError. Formerly, the
convert code would fall off the end and improperly return None.
Beefed-up tests.
* Test delimiter override for all paths in substitute and safe_substitute.
* Alter unittest invocation to match other modules (now it itemizes the
tests as they are run).
SF #1027105: HardwareRandom should be renamed OSRandom
Renamed the new generator at Trevor's recommendation.
The name HardwareRandom suggested a bit more than it
delivered (no radioactive decay detectors or such).
Barry Warsaw [Mon, 13 Sep 2004 20:52:50 +0000 (20:52 +0000)]
Raymond's good suggestion to re-order the tests in the convert() helper so the
most common paths are tested first. Also, that 'invalid' is better than
'bogus'.
Tim Peters [Mon, 13 Sep 2004 14:53:28 +0000 (14:53 +0000)]
exclude_empty: make the default True for DocTestFinder, and introduce it
with default False for testmod(). The real point of introducing this was
so that output from doctest.master.summarize() would be the same as in
2.3, and doctest.master in 2.4 is a backward-compatability hack used only
by testmod().
Barry Warsaw [Mon, 13 Sep 2004 14:35:04 +0000 (14:35 +0000)]
Accepted Raymond's patch to combine mapping and keyword arguments, with slight
modification. Also, renamed the positional argument to '__mapping' to further
reduce the chance of duplicate keyword arguments.
Edward Loper [Mon, 13 Sep 2004 05:47:24 +0000 (05:47 +0000)]
Added new parameter exclude_empty to DocTestFinder.__init__, which
controls whether tests are included for objects with empty docstrings.
Defaults to True, to match the behavior of Python 2.3.
Tim Peters [Mon, 13 Sep 2004 01:07:12 +0000 (01:07 +0000)]
DocTestFinder._find(): for tests derived from a module __test__ global,
doctest always promised to stick "__test__" in the name. That got
broken. Now it's fixed again.
The list resizing scheme only downsized when more than 16 elements were
removed in a single step: del a[100:120]. As a result, the list would
never shrink when popping elements off one at a time.
This patch makes it shrink whenever more than half of the space is unused.
Also, at Tim's suggestion, renamed _new_size to new_allocated. This makes
the code easier to understand.
Patch #1025795: clarify language in Data Structures chapter of tutorial:
- Dictionary keys are in arbitrary order, but not random (which implies, well,
intentional randomness).
- Move a footnote closer to what it's talking about so that it doesn't look
like we're saying that "0 == 0.0" can't be relied on.
- Minor language tweaks in the vicinity.
Tim Peters [Sat, 11 Sep 2004 17:33:27 +0000 (17:33 +0000)]
Recover from inspect.getmodule() changes. It returns a module for
functions and methods now, including functions defined inside doctests
in test_doctest.py's recursive doctest'ing.
Use __module__ attribute when available instead of using isclass() predicate
(functions and methods have grown the __module__ attribute too). See bug #570300.
Barry Warsaw [Fri, 10 Sep 2004 03:08:08 +0000 (03:08 +0000)]
Many updates to PEP 292 templates. Summary:
- Template no longer inherits from unicode.
- SafeTemplate is removed. Now Templates have both a substitute() and a
safe_substitute() method, so we don't need separate classes. No more
__mod__() operator.
- Adopt Tim Peter's idea for giving Template a metaclass, which makes the
delimiter, the identifier pattern, or the entire pattern easy to override
and document, while retaining efficiency of class-time compilation of the
regexp.
- More informative ValueError messages which will help a user narrow down the
bogus delimiter to the line and column in the original string (helpful for
long triple quoted strings).