| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
It was easier than I thought, assuming that no other things contribute
to the instance size besides slots -- a pretty good bet. With a test
suite, no less!
|
|
|
|
|
|
|
|
|
| |
happy if one could delete the __dict__ attribute of an instance. I
love to make Jim happy, so here goes...
- New-style objects now support deleting their __dict__. This is for
all intents and purposes equivalent to assigning a brand new empty
dictionary, but saves space if the object is not used further.
|
|
|
|
|
|
|
| |
int_mul(): new and vastly simpler overflow checking. Whether it's
faster or slower will likely vary across platforms, favoring boxes
with fast floating point. OTOH, we no longer have to worry about
people shipping broken LONG_BIT definitions <0.9 wink>.
|
|
|
|
|
|
|
| |
There's now a new structmember code, T_OBJECT_EX, which is used for
all __slot__ variables (except __weakref__, which has special behavior
anyway). This new code raises AttributeError when the variable is
NULL rather than converting NULL to None.
|
|
|
|
|
| |
result would overflow an int. Check for this. (SF bug #488482, Armin
Rigo.)
|
|
|
|
|
|
|
| |
string object (or a Unicode that's trivially converted to ASCII).
PyObject_GetAttr(): add an 'else' to the Unicode test like
PyObject_SetAttr() already has.
|
|
|
|
|
| |
Py_DECREF(arg) after the PyErr_NoMemory() call. (Armin Rigo, SF bug
#488477.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rather than tweaking the inheritance of type object slots (which turns
out to be too messy to try), this fix adds a __hash__ to the list and
dict types (the only mutable types I'm aware of) that explicitly
raises an error. This has the advantage that list.__hash__([]) also
raises an error (previously, this would invoke object.__hash__([]),
returning the argument's address); ditto for dict.__hash__.
The disadvantage for this fix is that 3rd party mutable types aren't
automatically fixed. This should be added to the rules for creating
subclassable extension types: if you don't want your object to be
hashable, add a tp_hash function that raises an exception.
Also, it's possible that I've forgotten about other mutable types for
which this should be done.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
SF patch #480716 by Greg Chapman fixes the problem that super's
__get__ method always returns an instance of super, even when the
instance whose __get__ method is called is an instance of a subclass
of super.
Other issues fixed:
- super(C, C()).__class__ would return the __class__ attribute of C()
rather than the __class__ attribute of the super object. This is
confusing. To fix this, I decided to change the semantics of super
so that it only applies to code attributes, not to data attributes.
After all, overriding data attributes is not supported anyway.
- While super(C, x) carefully checked that x is an instance of C,
super(C).__get__(x) made no such check, allowing for a loophole.
This is now fixed.
|
| |
|
|
|
|
| |
instead of PyOS_snprintf; add some relevant comments and asserts.
|
|
|
|
|
|
|
|
| |
slot_tp_descr_set(): When deleting an attribute described by a
descriptor implemented in Python, the descriptor's __del__ method is
called by the slot_tp_descr_set dispatch function. This is bogus --
__del__ already has a different meaning. Renaming this use of __del__
is renamed to __delete__.
|
| |
|
|
|
|
|
|
|
|
| |
Bugfix candidate.
int_repr(): we've never had a buffer big enough to hold the largest
possible result on a 64-bit box. Now that we're using snprintf instead
of sprintf, this can lead to nonsense results instead of random stack
corruption.
|
|
|
|
| |
changes from start of branch upto r22b2 were already merged, of course).
|
|
|
|
|
|
|
| |
pass the buffer length. Stop using it. It should be deprecated, but too
late in the release cycle to do that now.
New static format_float() does the same thing but requires passing the
buffer length too. Use it instead.
|
|
|
|
|
|
| |
const char* instead of char*. The change is conceptually correct, and
indirectly fixes a compiler wng introduced when somebody else innocently
passed a const char* to this function.
|
|
|
|
| |
PyOS_snprintf() for buffer overrun avoidance.
|
|
|
|
| |
for buffer overrun avoidance.
|
|
|
|
| |
overrun avoidance.
|
|
|
|
| |
sprintf() to PyOS_snprintf() for buffer overrun avoidance.
|
|
|
|
| |
buffer overrun avoidance.
|
|
|
|
|
|
|
| |
sprintf() to PyOS_snprintf() for buffer overrun avoidance.
complex_print(), complex_repr(), complex_str(): Call complex_to_buf()
passing in sizeof(buf).
|
|
|
|
|
| |
Also changed <>-style #includes to ""-style in some places where the
former didn't make sense.
|
| |
|
| |
|
|
|
|
|
|
|
| |
confusing error messages. If a new-style class has no sequence or
mapping behavior, attempting to use the indexing notation with a
non-integer key would complain that the sequence index must be an
integer, rather than complaining that the operation is not supported.
|
|
|
|
|
| |
This patch also does away with an incompatibility between Jython
and CPython.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
supports the single-segment readable buffer interface.
Add documentation for this and other PyObject_XXXBuffer() calls.
|
| |
|
|
|
|
|
|
| |
object, so the "Metroworks only" section should not decref it in case
of error (the caller is responsible for decref'ing in case of error --
and does).
|
|
|
|
|
|
| |
If fopen() fails with EINVAL it means that the mode argument is
invalid. Return the mode in the error message instead of the
filename.
|
|
|
|
|
| |
run in an infinite loop no longer grows. Thanks to Neal Norwitz for
determining that test leaked!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
helping for types that defined tp_richcmp but not tp_compare, although
that's when it's most valuable, and strings moved into that category
since the fast path was first introduced. Now it helps for same-type
non-Instance objects that define rich or 3-way compares.
For all the edits here, the rest just amounts to moving the fast path from
do_richcmp into PyObject_RichCompare, saving a layer of function call
(measurable on my box!). This loses when NESTING_LIMIT is exceeded, but I
don't care about that (fast-paths are for normal cases, not pathologies).
Also added a tasteful <wink> label to get out of PyObject_RichCompare, as
the if/else nesting in this routine was getting incomprehensible.
|
|
|
|
| |
the internal comparison routines.
|
|
|
|
|
| |
from optimizing away mod's sign adjustment when mod == 0; so it got
the intended result only in the debug build.
|
|
|
|
|
|
|
| |
Try to ensure that divmod(-0.0, 1.0) -> (-0.0, +0.0) across platforms.
It always did on Windows, and still does. It didn't on Linux. Alas,
there's no platform-independent way to write a test case for this.
Bugfix candidate.
|
|
|
|
|
|
| |
presence of NaNs. So pass the issue on to the platform libm fabs();
after all, fabs() is a std C function because you can't implement it
correctly in portable C89.
|
|
|
|
|
|
|
| |
should just avoid calling it in the first place to avoid waiting for a repr
of a large object like a dict or list. The result of PyObject_Repr() was
being leaked as well.
Bugfix candidate!
|
|
|
|
|
|
| |
Partial fix.
float_abs(): ensure abs(-0.0) returns +0.0.
Bugfix candidate.
|
|
|
|
|
|
| |
[ #476557 ] Wrong error message for file.write(a, b)
Makes file.write a METH_VARARGS function.
|
|
|
|
|
|
| |
Jack Jansen on python-dev.
Add simple test case.
Move vereq() from test_descr to test_support (it's handy!).
|
|
|
|
| |
return the same as dir(None).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
XXX Remaining problems:
- The GC module doesn't know about these; I think it has its reasons
to disallow calling __del__, but for now, __del__ on new-style
objects is called when the GC module discards an object, for better
or for worse.
- The code to call a __del__ handler is really ridiculously
complicated, due to all the different debug #ifdefs. I've copied
this from the similar code in classobject.c, so I'm pretty sure I
did it right, but it's not pretty. :-(
- No tests yet.
|
| |
|
|
|
|
| |
PyObject_CallMethodObArgs() ---> PyObject_CallMethodObjArgs()
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
object.h: Added PyType_CheckExact macro.
typeobject.c, type_new():
+ Use the new macro.
+ Assert that the arguments have the right types rather than do incomplete
runtime checks "sometimes".
+ If this isn't the 1-argument flavor() of type, and there aren't 3 args
total, produce a "types() takes 1 or 3 args" msg before
PyArg_ParseTupleAndKeywords produces a "takes exactly 3" msg.
|
|
|
|
|
|
| |
+ Change keyword arg name from "x" to "items". People passing a mapping
object can stretch their imaginations <wink>.
+ Simplify the docstring text.
|