Commit Graph

3075 Commits

Author SHA1 Message Date
Mark Dickinson efc82f7e8e Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Backport of r70459.
2009-03-20 15:51:55 +00:00
Benjamin Peterson 6ffe852f90 fix strange errors when setting attributes on tracebacks #4034 2009-03-18 20:52:15 +00:00
Mark Dickinson 6b265f1bf8 Issue 4474: On platforms with sizeof(wchar_t) == 4 and
sizeof(Py_UNICODE) == 2, PyUnicode_FromWideChar now converts
each character outside the BMP to the appropriate surrogate pair.

Thanks Victor Stinner for the patch.

(backport of r70452 from py3k to trunk)
2009-03-18 16:07:26 +00:00
Georg Brandl ed4cefbedd Fix a small nit in the error message if bool() falls back on __len__ and it returns the wrong type: it would tell the user that __nonzero__ should return bool or int. 2009-03-15 21:43:38 +00:00
Benjamin Peterson 1706c644ae fix tuple.index() error message #5495 2009-03-15 14:38:55 +00:00
Eric Smith 6f42edb682 Issue 5237, Allow auto-numbered replacement fields in str.format() strings.
For simple uses for str.format(), this makes the typing easier. Hopfully this
will help in the adoption of str.format().

For example:
'The {} is {}'.format('sky', 'blue')

You can mix and matcth auto-numbering and named replacement fields:
'The {} is {color}'.format('sky', color='blue')

But you can't mix and match auto-numbering and specified numbering:
'The {0} is {}'.format('sky', 'blue')
ValueError: cannot switch from manual field specification to automatic field numbering

Will port to 3.1.
2009-03-14 11:57:26 +00:00
Benjamin Peterson 9c1f7b2b04 fix funky indentation 2009-03-08 00:21:17 +00:00
Hirokazu Yamamoto a3e6c9763c Fixed memory leak on failure. 2009-03-05 09:34:14 +00:00
Mark Dickinson b646487687 Replace long with twodigits, to avoid depending
on sizeof(digit) < sizeof(long)
2009-02-25 20:29:50 +00:00
Mark Dickinson 3e4caeb3bf Issue #5341: Fix a variety of spelling errors. 2009-02-21 20:27:01 +00:00
Eric Smith e9fb6863da Issue #5247: Improve error message when unknown format codes are used when using str.format() with str, unicode, long, int, and float arguments. 2009-02-20 14:02:36 +00:00
Mark Dickinson bcf6b18eb7 A few more minor fixes in longobject.c 2009-02-15 15:48:39 +00:00
Mark Dickinson 2ffb26fb83 Issue #5260: Various portability and standards compliance fixes, optimizations
and cleanups in Objects/longobject.c.  The most significant change is that
longs now use less memory:  average savings are 2 bytes per long on 32-bit
systems and 6 bytes per long on 64-bit systems.  (This memory saving already
exists in py3k.)
2009-02-15 10:13:41 +00:00
Antoine Pitrou 9e8a250ed9 Fix compiler warning (gcc) 2009-02-13 13:57:40 +00:00
Antoine Pitrou 76a4b896c4 Issue #5186: Reduce hash collisions for objects with no __hash__ method by
rotating the object pointer by 4 bits to the right.
2009-02-13 13:52:33 +00:00
Georg Brandl cbb4958cd8 Fix warnings GCC emits where the argument of PyErr_Format is a single variable. 2009-02-13 11:06:59 +00:00
Mark Dickinson 4015f62e39 Issue #5175: PyLong_AsUnsignedLongLong now raises OverflowError for
negative arguments.  Previously, it raised TypeError.

Thanks Lisandro Dalcin.
2009-02-10 15:46:50 +00:00
Kristján Valur Jónsson 6a743d3694 Issue 4804. Add a function to test the validity of file descriptors on Windows, and stop using global runtime settings to silence the warnings / assertions. 2009-02-10 13:32:24 +00:00
Mark Dickinson 10fe877dcd Issue #789290: make sure that hash(2**63) == hash(2.**63) on 64-bit
platforms.  The previous code was fragile, depending on the twin
accidents that:

  (1) in C, casting the double value 2.**63 to long returns the integer
      value -2**63, and
  (2) in Python, hash(-2**63) == hash(2**63).

There's already a test for this in test_hash.
2009-02-08 14:42:28 +00:00
Mark Dickinson b91d2f5bd3 Remove redundant assignment in _PyObject_LengthHint 2009-02-08 13:58:10 +00:00
Kristján Valur Jónsson fd4c872726 issue 4804: Provide checks for the format string of strftime, and for the "mode" string of fopen on Windows. These strings are user provided from python and so we can avoid invoking the C runtime invalid parameter handler by first checking that they are valid. 2009-02-04 10:05:25 +00:00
Raymond Hettinger d6fc2623c5 Validate that __length_hint__ returns a usable result. 2009-02-03 02:23:19 +00:00
Raymond Hettinger b516370bcb Issue 1242657: list(obj) can swallow KeyboardInterrupt. 2009-02-02 21:50:13 +00:00
Benjamin Peterson 1c5d21d644 fix indentation in comment 2009-01-31 22:33:02 +00:00
Benjamin Peterson be1399e39a fix indentation; looks like all I managed to do the first time is make things uglier 2009-01-31 22:03:19 +00:00
Benjamin Peterson d17fec74e5 fix indentation 2009-01-31 21:47:42 +00:00
Benjamin Peterson 857ce15791 completely detabify unicodeobject.c 2009-01-31 16:29:18 +00:00
Mark Dickinson a0eae0398c Fix comment. 2009-01-26 21:40:08 +00:00
Mark Dickinson 6ffa4a2a7d Fix undefined behaviour (left shift of negative value) in long_hash. Also,
rewrap a line of length > 79, and update comments.
2009-01-26 21:36:30 +00:00
Mark Dickinson 1afe6ddd07 No need for carry to be type twodigits in _PyLong_AsByteArray; digit is large enough.
This change should silence a compiler warning on Windows.
2009-01-25 22:12:31 +00:00
Hirokazu Yamamoto 1e234e8c19 Fixed compile error on windows. 2009-01-25 17:46:48 +00:00
Benjamin Peterson 78821ddf8c fix building the core with --disable-unicode
I changed some bytearray methods to use strings instead of unicode like bytes_repr
Also, bytearray.fromhex() can take strings as well as unicode
2009-01-25 17:15:10 +00:00
Mark Dickinson ff84aa87b4 Issue #4393: fix 3 classes of potential portability problems in longobject.c:
- fix some places where counters into ob_digit were declared as
   int instead of Py_ssize_t
 - add (twodigit) casts where necessary
 - fix code in _PyLong_AsByteArray that uses << on negative values
2009-01-24 15:27:44 +00:00
Benjamin Peterson e548d2487d fix url 2009-01-20 18:58:27 +00:00
Amaury Forgeot d'Arc 59ce042766 #4077: No need to append \n when calling Py_FatalError
+ fix a declaration to make it match the one in pythonrun.h
2009-01-17 20:18:59 +00:00
Amaury Forgeot d'Arc bd55c52565 #4930: Slightly cleaner (and faster) code in type creation:
compare slots by address, not by name.
2009-01-17 17:11:50 +00:00
Antoine Pitrou c2f02216b6 Issue #4935: The overflow checking code in the expandtabs() method common
to str, bytes and bytearray could be optimized away by the compiler, letting
the interpreter segfault instead of raising an error.
2009-01-13 23:13:52 +00:00
Amaury Forgeot d'Arc a40d573664 #3720: Interpreter crashes when an evil iterator removes its own next function.
Now the slot is filled with a function that always raises.

Will not backport: extensions compiled with 2.6.x would not run on 2.6.0.
2009-01-12 23:36:55 +00:00
Martin v. Löwis b90304acb9 Issue #4850: Change COUNT_ALLOCS variables to Py_ssize_t. 2009-01-07 18:40:40 +00:00
Antoine Pitrou aa687902f2 Issue #3680: Reference cycles created through a dict, set or deque iterator did not get collected. 2009-01-01 14:11:22 +00:00
Nick Coghlan 180e400766 Issue #4701: implicitly call PyType_Ready from PyObject_Hash 2008-12-30 01:18:48 +00:00
Benjamin Peterson fe231b07e4 #4764 set IOError.filename when trying to open a directory on POSIX platforms 2008-12-29 17:47:42 +00:00
Georg Brandl 6425a2fa8f Backport r67974:
#4759: allow None as first argument of bytearray.translate(), for consistency with bytes.translate().

Also fix segfault for bytearray.translate(x, None) -- will backport this part to 3.0 and 2.6.
2008-12-28 11:54:53 +00:00
Alexandre Vassalotti 034e08ce8d Remove unnecessary casts related to unicode_decode_call_errorhandler.
Make the _PyUnicode_Resize macro a static function.

These changes are needed to avoid breaking strict aliasing rules.
2008-12-27 06:36:10 +00:00
Benjamin Peterson f09925da67 add py3k warnings to frame.f_exc_* 2008-12-22 20:16:25 +00:00
Mark Dickinson 1a707981c8 Issue #3439: add bit_length method to int and long.
Thanks Fredrik Johansson and Victor Stinner for code,
Raymond Hettinger for review.
2008-12-17 16:14:37 +00:00
Amaury Forgeot d'Arc 3538a3107a #3632: the "pyo" macro from gdbinit can now run when the GIL is released.
Patch by haypo.
2008-12-15 22:29:14 +00:00
Antoine Pitrou ae5beceb35 Issue #4509: bugs in bytearray with exports (buffer protocol) 2008-12-06 21:29:24 +00:00
Mark Dickinson 826f3fefe5 Issue #4445: save 3 bytes (on average, on a typical machine) per
string allocation.
2008-12-05 21:55:28 +00:00
Raymond Hettinger 7989a4dccb Backport r67478 2008-12-03 15:42:10 +00:00