summaryrefslogtreecommitdiff
path: root/Objects/unicodeobject.c
AgeCommit message (Collapse)AuthorLines
2008-12-13Backported r55839 and r61350Martin v. Löwis-9/+34
Issue #4469: Prevent expandtabs() on string and unicode objects from causing a segfault when a large width is passed on 32-bit platforms.
2008-07-31Security patches from Apple: prevent int overflow when allocating memoryNeal Norwitz-10/+39
2006-10-05[Backport r50743 | neal.norwitz]Andrew M. Kuchling-0/+3
Handle allocation failures gracefully. Found with failmalloc. Many (all?) of these could be backported.
2006-10-04A review of overflow-detecting code in the 2.4 branch.Armin Rigo-0/+2
* unified the way intobject, longobject and mystrtoul handle values around -sys.maxint-1. * in general, trying to entierely avoid overflows in any computation involving signed ints or longs is extremely involved. Fixed a few simple cases where a compiler might be too clever (but that's all guesswork). * more overflow checks against bad data in marshal.c.
2006-09-29[Backport rev. 39743 by lemburg]Andrew M. Kuchling-8/+16
Bug fix for [ 1331062 ] utf 7 codec broken. Backport candidate.
2006-08-22Backport rev 51448:Georg Brandl-12/+25
- Patch #1541585: fix buffer overrun when performing repr() on a unicode string in a build with wide unicode (UCS-4) support.
2006-06-05Don't crash on Py_UNICODE values < 0. Fixes #1454485.Martin v. Löwis-1/+3
2006-05-15Backport: Patch #1488312, Fix memory alignment problem on SPARC in unicode.Neal Norwitz-1/+1
2006-03-28after discussions with perky, reverted fix for Bug #1379994: BuiltinAnthony Baxter-3/+3
unicode_escape and raw_unicode_escape codec now encodes backslash correctly. This caused another issue for unicode repr strings being double-escaped (SF Bug #1459029). Correct fix will be in 2.5, but is too risky for 2.4.3. Added a testcase for #1459029.
2006-03-28Fix the refleak from test_unicode.Neal Norwitz-13/+16
Backport 42973 (lots of whitespace changes intermixed): - Reindent a confusingly indented piece of code (no intended code changes there) - Add missing DECREFs of inner-scope 'temp' variable - Add various missing DECREFs by changing 'return NULL' into 'goto onError' - Avoid double DECREF when last _PyUnicode_Resize() fails Coverity found one of the missing DECREFs, but oddly enough not the others.
2006-03-07Backport r42894: SF #1444030 Fix several potential defects foundHye-Shik Chang-8/+14
by Coverity.
2006-01-10Backport:Neal Norwitz-16/+21
- Patch #1400181, fix unicode string formatting to not use the locale. This is how string objects work. u'%f' could use , instead of . for the decimal point. Now both strings and unicode always use periods. This is the code that would break: import locale locale.setlocale(locale.LC_NUMERIC, 'de_DE') u'%.1f' % 1.0 assert '1.0' == u'%.1f' % 1.0 I couldn't create a test case which fails, but this fixes the problem. (tested in interpreter and reported fixed by others)
2005-12-17Bug #1379994: Fix *unicode_escape codecs to encode r'\' as r'\\'Hye-Shik Chang-3/+3
just like string codecs.
2005-11-28Backport checkin:Walter Dörwald-0/+1
Fix leaked reference to None.
2005-08-30Backport checkin:Walter Dörwald-0/+75
SF bug #1251300: On UCS-4 builds the "unicode-internal" codec will now complain about illegal code points. The codec now supports PEP 293 style error handlers. (This is a variant of the patch by Nik Haldimann that detects truncated data)
2004-11-22Correct the handling of 0-termination of PyUnicode_AsWideChar()Marc-André Lemburg-1/+7
and its usage in PyLocale_strcoll(). Clarify the documentation on this. Thanks to Andreas Degert for pointing this out.
2004-10-15Applied patch for [ 1047269 ] Buffer overwrite in PyUnicode_AsWideChar.Marc-André Lemburg-2/+2
Python 2.3.x candidate.
2004-09-16Initialize sep and seplen to suppress warning from gcc.Skip Montanaro-3/+3
2004-09-15Add a missing line continuation character.Thomas Heller-1/+1
2004-09-14Make the hint about the None default less ambiguous.Walter Dörwald-1/+1
2004-09-14Enhance the docstrings for unicode.split() and string.split()Walter Dörwald-2/+2
to make it clear that it is possible to pass None as the separator argument to get the default "any whitespace" separator.
2004-09-07SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now supportWalter Dörwald-23/+57
decoding incomplete input (when the input stream is temporarily exhausted). codecs.StreamReader now implements buffering, which enables proper readline support for the UTF-16 decoders. codecs.StreamReader.read() has a new argument chars which specifies the number of characters to return. codecs.StreamReader.readline() and codecs.StreamReader.readlines() have a new argument keepends. Trailing "\n"s will be stripped from the lines if keepends is false. Added C APIs PyUnicode_DecodeUTF8Stateful and PyUnicode_DecodeUTF16Stateful.
2004-08-27PyUnicode_Join(): Bozo Alert. While this is chugging along, it mayTim Peters-0/+12
need to convert str objects from the iterable to unicode. So, if someone set the system default encoding to something nasty enough, the conversion process could mutate the input iterable as a side effect, and PySequence_Fast doesn't hide that from us if the input was a list. IOW, can't assume the size of PySequence_Fast's result is invariant across PyUnicode_FromObject() calls.
2004-08-27PyUnicode_Join(): Rewrote to use PySequence_Fast(). This doesn't doTim Peters-125/+95
much to reduce the size of the code, but greatly improves its clarity. It's also quicker in what's probably the most common case (the argument iterable is a list). Against it, if the iterable isn't a list or a tuple, a temp tuple is materialized containing the entire input sequence, and that's a bigger temp memory burden. Yawn.
2004-08-27PyUnicode_Join(): Missed a spot where I intended a cast from size_t toTim Peters-1/+1
int. I sure wish MS would gripe about that! Whatever, note that the statement above it guarantees that the cast loses no info.
2004-08-27PyUnicode_Join(): Two primary aims:Tim Peters-40/+120
1. u1.join([u2]) is u2 2. Be more careful about C-level int overflow. Since PySequence_Fast() isn't needed to achieve #1, it's not used -- but the code could sure be simpler if it were.
2004-08-04SF #989185: Drop unicode.iswide() and unicode.width() and addHye-Shik Chang-67/+0
unicodedata.east_asian_width(). You can still implement your own simple width() function using it like this: def width(u): w = 0 for c in unicodedata.normalize('NFC', u): cwidth = unicodedata.east_asian_width(c) if cwidth in ('W', 'F'): w += 2 else: w += 1 return w
2004-07-23Let u'%s' % obj try obj.__unicode__() first and fallback to obj.__str__().Marc-André Lemburg-10/+12
2004-07-15Moved SunPro warning suppression into pyport.h and out of individualNicholas Bastin-4/+0
modules and objects.
2004-07-10Fix a copy&paste typo.Marc-André Lemburg-1/+1
2004-07-08.encode()/.decode() patch part 2.Marc-André Lemburg-0/+10
2004-07-08Allow string and unicode return types from .encode()/.decode()Marc-André Lemburg-5/+95
methods on string and unicode objects. Added unicode.decode() which was missing for no apparent reason.
2004-06-17Fixed end-of-loop code not reached warning when using SunPro CNicholas Bastin-0/+4
2004-06-02- SF #962502: Add two more methods for unicode type; width() andHye-Shik Chang-1/+68
iswide() for east asian width manipulation. (Inspired by David Goodger, Reviewed by Martin v. Loewis) - Move _PyUnicode_TypeRecord.flags to the end of the struct so that no padding is added for UCS-4 builds. (Suggested by Martin v. Loewis)
2004-04-06SF Patch #926375: Remove a useless UTF-16 support code that is neverHye-Shik Chang-18/+3
been used. (Suggested by Martin v. Loewis)
2004-02-05Fix reallocation bug in unicode.translate(): The code was comparingWalter Dörwald-1/+1
characters instead of character pointers to determine space requirements.
2004-01-03Cosmetic fix for wrongly indented tabs with ts=4.Hye-Shik Chang-8/+8
2003-12-23Fix unicode.rsplit()'s bug that ignores separater on the end of string whenHye-Shik Chang-1/+1
using specialized splitter for 1 char sep.
2003-12-22Fix broken xmlcharrefreplace by rev 2.204.Hye-Shik Chang-3/+3
(Pointy hat goes to perky)
2003-12-19SF #859573: Reduce compiler warnings on gcc 3.2 and above.Hye-Shik Chang-1/+14
2003-12-15Add rsplit method for str and unicode builtin types.Hye-Shik Chang-1/+191
SF feature request #801847. Original patch is written by Sean Reifschneider.
2003-11-29- Removed FutureWarnings related to hex/oct literals and conversionsGuido van Rossum-17/+19
and left shifts. (Thanks to Kalle Svensson for SF patch 849227.) This addresses most of the remaining semantic changes promised by PEP 237, except for repr() of a long, which still shows the trailing 'L'. The PEP appears to promise warnings for operations that changed semantics compared to Python 2.3, but this is not implemented; we've suffered through enough warnings related to hex/oct literals and I think it's best to be silent now.
2003-11-26Add optional fillchar argument to ljust(), rjust(), and center() string methods.Raymond Hettinger-13/+45
2003-10-24Fix a bug in the memory reallocation code of PyUnicode_TranslateCharmap().Walter Dörwald-19/+20
charmaptranslate_makespace() allocated more memory than required for the next replacement but didn't remember that fact, so memory size was growing exponentially every time a replacement string is longer that one character. This fixes SF bug #828737.
2003-10-18Patch #825679: Clarify semantics of .isfoo on empty strings.Martin v. Löwis-10/+11
Backported to 2.3.
2003-10-06Fix for SF bug [ 817156 ] invalid \U escape gives 0=length unistr.Jeremy Hylton-1/+1
2003-09-16On c.l.py, Martin v. Löwis said that Py_UNICODE could be of a signed type,Tim Peters-137/+145
so fiddle Jeremy's fix to live with that. Also added more comments. Bugfix candidate (this bug is in all versions of Python, at least since 2.1).
2003-09-16Double-fix of crash in Unicode freelist handling.Jeremy Hylton-2/+7
If a length-1 Unicode string was in the freelist and it was uninitialized or pointed to a very large (magnitude) negative number, the check unicode_latin1[unicode->str[0]] == unicode could cause a segmentation violation, e.g. unicode->str[0] is 0xcbcbcbcb. Fix this in two ways: 1. Change guard befor unicode_latin1[] to test against 256U. If I understand correctly, the unsigned long used to store UCS4 on my box was getting converted to a signed long to compare with the signed constant 256. 2. Change _PyUnicode_New() to make sure the first element of str is always initialized to zero. There are several places in the code where the caller can exit with an error before initializing any of str, which would leave junk in str[0]. Also, silence a compiler warning on pointer vs. int arithmetic. Bug fix candidate.
2003-09-16Change checks of PyUnicode_Resize() return value for clarity.Jeremy Hylton-18/+17
The unicode_resize() family only returns -1 or 0 so simply checking for != 0 is sufficient, but somewhat unclear. Many Python API functions return < 0 on error, reserving the right to return 0 or 1 on success. Change the call sites for consistency with these calls.
2003-08-27SF bug #795506: Wrong handling of string format code for float values.Raymond Hettinger-0/+3
Adding missing support for '%F'. Will backport to 2.3.1.