Checkin Tim's fix to an error discussed on python-dev.
Also, add a testcase.
Formerly, the list_extend() code used several local variables to remember
its state across iterations. Since an iteration could call arbitrary
Python code, it was possible for the list state to be changed. The new
code uses dynamic structure references instead of C locals. So, they
are always up-to-date.
After list_resize() is called, its size has been updated but the new
cells are filled with NULLs. These needed to be filled before arbitrary
iteration code was called; otherwise, that code could attempt to modify
a list that was in a semi-invalid state. The solution was to change
the ob->size field back to a value reflecting the actual number of valid
cells.
Tim Peters [Sun, 26 Sep 2004 01:24:23 +0000 (01:24 +0000)]
Removed two undocumented unittest support classes, and one undocumented
unittest support function, from the public interface. If they're not
documented, they shouldn't be public.
Tim Peters [Sat, 25 Sep 2004 00:49:53 +0000 (00:49 +0000)]
Beef up the section on testfile(), giving a complete example in
reStructuredText format. Remove words describing the return value of
testmod() and testfile() in the intro sections, since it's never
useful in such simple cases.
Neil Schemenauer [Fri, 24 Sep 2004 19:17:26 +0000 (19:17 +0000)]
Ensure negative offsets cannot be passed to buffer(). When composing
buffers, compute the new buffer size based on the old buffer size.
Fixes SF bug #1034242.
Tim Peters [Thu, 23 Sep 2004 19:22:41 +0000 (19:22 +0000)]
float_richcompare(): Use the new Py_IS_NAN macro to ensure that, on
platforms where that macro works, NaN compared to an int or long works
the same as NaN compared to a finite float.
Tim Peters [Thu, 23 Sep 2004 19:11:32 +0000 (19:11 +0000)]
Introduced a Py_IS_NAN macro, which probably works on the major platforms
today. pyconfig.h can override it if not, and can also override
Py_IS_INFINITY now. Py_IS_NAN and Py_IS_INFINITY are overridden now
for Microsoft compilers, using efficient MS-specific spellings.
Tim Peters [Thu, 23 Sep 2004 08:06:40 +0000 (08:06 +0000)]
SF bug #513866: Float/long comparison anomaly.
When an integer is compared to a float now, the int isn't coerced to float.
This avoids spurious overflow exceptions and insane results. This should
compute correct results, without raising spurious exceptions, in all cases
now -- although I expect that what happens when an int/long is compared to
a NaN is still a platform accident.
Note that we had potential problems here even with "short" ints, on boxes
where sizeof(long)==8. There's #ifdef'ed code here to handle that, but
I can't test it as intended. I tested it by changing the #ifdef to
trigger on my 32-bit box instead.
I suppose this is a bugfix candidate, but I won't backport it. It's
long-winded (for speed) and messy (because the problem is messy). Note
that this also depends on a previous 2.4 patch that introduced
_Py_SwappedOp[] as an extern.
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