Commit Graph

2740 Commits

Author SHA1 Message Date
Georg Brandl d7e9f608c3 Revert accidental checkins from last commit. 2007-08-21 06:03:43 +00:00
Georg Brandl fdca6d8599 Demand version 2.5.1 since 2.5 has a bug with codecs.open context managers. 2007-08-21 06:01:18 +00:00
Walter Dörwald 9ab80a9fb4 Move another variable declaration up. 2007-08-17 16:58:43 +00:00
Walter Dörwald 20b40d3bce Move variable declaration up. 2007-08-17 16:52:50 +00:00
Walter Dörwald 6e39080649 Backport r57105 and r57145 from the py3k branch: UTF-32 codecs. 2007-08-17 16:41:28 +00:00
Georg Brandl 9efd9b6fa4 Bug #1763149: use proper slice syntax in docstring.
(backport)
2007-07-29 17:38:35 +00:00
Martin v. Löwis 6819210b9e PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
2007-07-21 06:55:02 +00:00
Georg Brandl 7c3b50db66 Patch #1673759: add a missing overflow check when formatting floats
with %G.
2007-07-12 08:38:00 +00:00
Walter Dörwald 84a3efec37 Add T_PYSSIZET in structmember.h: This can be used for
Py_ssize_t members.

Simplify the implementation of UnicodeError objects:
start and end attributes are now stored directly as
Py_ssize_t members, which simplifies various get and
set functions.
2007-06-13 16:57:12 +00:00
Neal Norwitz 5c9a81a3d8 Fix a bug when there was a newline in the string expandtabs was called on.
This also catches another condition that can overflow.

Will backport.
2007-06-11 02:16:10 +00:00
Neal Norwitz 7dbd2a3720 Prevent expandtabs() on string and unicode objects from causing a segfault when
a large width is passed on 32-bit platforms.  Found by Google.

It would be good for people to review this especially carefully and verify
I don't have an off by one error and there is no other way to cause overflow.
2007-06-09 03:36:34 +00:00
Martin v. Löwis da587ab43e Bug #1733488: Fix compilation of bufferobject.c on AIX.
Will backport to 2.5.
2007-06-08 17:29:20 +00:00
Neal Norwitz 0ac601995c Add the new function object attribute names from py3k. 2007-05-27 04:08:54 +00:00
Neal Norwitz c792629c83 Whitespace cleanup 2007-05-23 06:57:35 +00:00
Neal Norwitz 8b2bfbc198 Add -3 option to the interpreter to warn about features that are
deprecated and will be changed/removed in Python 3.0.

This patch is mostly from Anthony.  I tweaked some format and added
a little doc.
2007-05-23 06:35:32 +00:00
Neal Norwitz a84dcd7546 Stop using METH_OLDARGS implicitly 2007-05-22 07:16:44 +00:00
Brett Cannon 5cd0fca9d8 Complete deprecation of BaseException.message. Some subclasses were directly
accessing the message attribute instead of using the descriptor.
2007-05-17 02:02:56 +00:00
Neal Norwitz d501d1fbc4 Port rev 55353 from Guido:
Add what looks like a necessary call to PyErr_NoMemory() when PyMem_MALLOC()
fails.

Will backport.
2007-05-16 04:33:50 +00:00
Guido van Rossum 360496d9c0 Fix a bug in test_c_api() that caused a negative refcount. 2007-05-10 17:20:15 +00:00
Kristján Valur Jónsson abe1d48d20 As per Armin Rigo's suggestion, remove special handing from intobject.c to deal with the peculiarities of classobject's implementation of the number protocol. The nb_long method of classobject now falls back to nb_int if there is no __long__ attribute present. 2007-05-07 16:46:54 +00:00
Brett Cannon 229cee2d3d Deprecate BaseException.message as per PEP 352. 2007-05-05 01:34:02 +00:00
Kristján Valur Jónsson f030394de3 Fix problems in x64 build that were discovered by the testsuite:
- Reenable modules on x64 that had been disabled aeons ago for Itanium.
- Cleared up confusion about compilers for 64 bit windows.  There is only Itanium and x64.  Added macros MS_WINI64 and MS_WINX64 for those rare cases where it matters, such as the disabling of modules above.
- Set target platform (_WIN32_WINNT and WINVER) to 0x0501 (XP) for x64, and 0x0400 (NT 4.0) otherwise, which are the targeted minimum platforms.
- Fixed thread_nt.h.  The emulated InterlockedCompareExchange function didn´t work on x64, probaby due to the lack of a "volatile" specifier.  Anyway, win95 is no longer a target platform.
- Itertools module used wrong constant to check for overflow in count()
- PyInt_AsSsize_t couldn't deal with attribute error when accessing the __long__ member.
- PyLong_FromSsize_t() incorrectly specified that the operand were unsigned.

With these changes, the x64 passes the testsuite, for those modules present.
2007-05-03 20:27:03 +00:00
Neal Norwitz 8b267b55ef Remove dead code. This code couldn't be reached because earlier in
the function there is another check for z != Py_None.
2007-05-03 07:20:57 +00:00
Armin Rigo 9790a27065 Fix for #1303614 and #1174712:
- __dict__ descriptor abuse for subclasses of built-in types
- subclassing from both ModuleType and another built-in types

Thanks zseil for the patch.
2007-05-02 19:23:31 +00:00
Kristján Valur Jónsson 0a440d4184 Export function sanitize_the_mode from fileobject.c as _PyFile_SanitizeMode(). Use this function in posixmodule.c when implementing fdopen(). This fixes test_subprocess.py for a VisualStudio 2005 compile. 2007-04-26 09:15:08 +00:00
Armin Rigo 796fc992ce Fix a usage of the dangerous pattern decref - modify field - incref. 2007-04-19 14:56:48 +00:00
Armin Rigo c0ba52d3fd Revert r53997 as per
http://mail.python.org/pipermail/python-dev/2007-March/071796.html .

I've kept a couple of still-valid extra tests in test_descr, but didn't
bother to sort through the new comments and refactorings added in r53997
to see if some of them could be kept.  If so, they could go in a
follow-up check-in.
2007-04-19 14:44:48 +00:00
Brett Cannon f64c90052f Silence a compiler warning about incompatible pointer types. 2007-04-19 03:44:17 +00:00
Neal Norwitz cbd9ee69ee When __slots__ are set to a unicode string, make it work the same as
setting a plain string, ie don't expand to single letter identifiers.
2007-04-14 05:25:50 +00:00
Kristján Valur Jónsson 2f2f57916c Fix a bug when using the __lltrace__ opcode tracer, and a problem sith signed chars in frameobject.c which can occur with opcodes > 127 2007-04-13 22:07:33 +00:00
Raymond Hettinger 4db5fe970c SF 1193128: Let str.translate(None) be an identity transformation 2007-04-12 04:10:00 +00:00
Raymond Hettinger 13936697f6 SF 1191699: Make slices picklable 2007-04-11 18:40:58 +00:00
Georg Brandl c02e13122b Add some missing NULL checks which trigger crashes on low-memory conditions.
Found by Victor Stinner. Will backport when 2.5 branch is unfrozen.
2007-04-11 17:16:24 +00:00
Guido van Rossum f102e24bd3 Add a type.__init__() method that enforces the same signature as
type.__new__(), and then calls object.__init__(cls), just to be anal.

This allows us to restore the code in string.py's _TemplateMetaclass
that called super(...).__init__(name, bases, dct), which I commented
out yesterday since it broke due to the stricter argument checking
added to object.__init__().
2007-03-23 18:53:03 +00:00
Guido van Rossum 143b564059 - Bug #1683368: The object.__init__() and object.__new__() methods are
now stricter in rejecting excess arguments.  The only time when
  either allows excess arguments is when it is not overridden and the
  other one is.  For backwards compatibility, when both are
  overridden, it is a deprecation warning (for now; maybe a Py3k
  warning later).

When merging this into 3.0, the warnings should become errors.

Note: without the change to string.py, lots of spurious warnings happen.
What's going on there?
2007-03-23 04:58:42 +00:00
Raymond Hettinger e3146f5aa3 Add test and fix for fromkeys() optional argument. 2007-03-21 20:33:57 +00:00
Raymond Hettinger 0bbbfc4c0b Extend work on rev 52962 and 53829 eliminating redundant PyObject_Hash() calls and fixing set/dict interoperability. 2007-03-20 21:27:24 +00:00
Georg Brandl 2b869943fa Patch #1675423: PyComplex_AsCComplex() now tries to convert an object
to complex using its __complex__() method before falling back to the
__float__() method. Therefore, the functions in the cmath module now
can operate on objects that define a __complex__() method.
 (backport)
2007-03-17 16:08:45 +00:00
Jeremy Hylton 26ca925838 Remove warning: funcion declaration isn't a prototype 2007-03-16 14:49:11 +00:00
Žiga Seilnacht 6f2d09c949 Patch #1623563: allow __class__ assignment for classes with __slots__.
The old and the new class are still required to have the same slot
names, but the order in which they are specified is not relevant.
2007-03-16 11:59:38 +00:00
Žiga Seilnacht 20f43d3018 Patch #1462488: prevent a segfault in object_reduce_ex() by splitting
the implementation for __reduce__ and __reduce_ex__ into two separate
functions. Fixes bug #931877. Will backport.
2007-03-15 11:44:55 +00:00
Žiga Seilnacht 71436f0229 Patch #1680015: Don't modify __slots__ tuple if it contains an unicode
name. Remove a reference leak that happened if the name could not be
converted to string. Will backport.
2007-03-14 12:24:09 +00:00
Georg Brandl 8f032cbb05 Patch #1642844: comments to clarify the complexobject constructor. 2007-03-13 07:57:51 +00:00
Georg Brandl 3bb156722e Typo and grammar fixes. 2007-03-13 07:23:16 +00:00
Georg Brandl 871f1bc601 Backport from Py3k branch:
Patch #1591665: implement the __dir__() special function lookup in PyObject_Dir.

Had to change a few bits of the patch because classobjs and __methods__ are still
in Py2.6.
2007-03-12 13:17:36 +00:00
Žiga Seilnacht 8903208776 Patch #1675981: remove unreachable code from type.__new__() method.
__dict__ and __weakref__ are removed from the slots tuple earlier
in the code, in the loop that mangles slot names. Will backport.
2007-03-11 15:54:54 +00:00
Collin Winter e38051db87 Patch #1491866: change the complex() constructor to allow parthensized forms. This means complex(repr(x)) now works instead of raising a ValueError. 2007-03-09 20:33:07 +00:00
Neal Norwitz 0593de32d9 Fix SF #1676971, Complex OverflowError has a typo 2007-03-09 05:59:01 +00:00
Georg Brandl 00cd818dea Patch #1638879: don't accept strings with embedded NUL bytes in long(). 2007-03-06 18:41:12 +00:00
Jeremy Hylton fa955697fa Add checking for a number of metaclass error conditions.
We add some new rules that are required for preserving internal
invariants of types.

1.  If type (or a subclass of type) appears in bases, it must appear
    before any non-type bases.  If a non-type base (like a regular
    new-style class) occurred first, it could trick type into
    allocating the new class an __dict__ which must be impossible.

2. There are several checks that are made of bases when creating a
   type.  Those checks are now repeated when assigning to __bases__.
   We also add the restriction that assignment to __bases__ may not
   change the metaclass of the type.

Add new tests for these cases and for a few other oddball errors that
were no previously tested.  Remove a crasher test that was fixed.

Also some internal refactoring:  Extract the code to find the most
derived metaclass of a type and its bases.  It is now needed in two
places.  Rewrite the TypeError checks in test_descr to use doctest.
The tests now clearly show what exception they expect to see.
2007-02-27 18:29:45 +00:00