summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
Commit message (Collapse)AuthorAgeFilesLines
* SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now supportWalter Dörwald2004-09-071-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.
* PyUnicode_Join(): Bozo Alert. While this is chugging along, it mayTim Peters2004-08-271-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.
* PyUnicode_Join(): Rewrote to use PySequence_Fast(). This doesn't doTim Peters2004-08-271-126/+96
| | | | | | | | 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.
* PyUnicode_Join(): Missed a spot where I intended a cast from size_t toTim Peters2004-08-271-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.
* PyUnicode_Join(): Two primary aims:Tim Peters2004-08-271-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.
* SF #989185: Drop unicode.iswide() and unicode.width() and addHye-Shik Chang2004-08-041-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
* Let u'%s' % obj try obj.__unicode__() first and fallback to obj.__str__().Marc-André Lemburg2004-07-231-10/+12
|
* Moved SunPro warning suppression into pyport.h and out of individualNicholas Bastin2004-07-151-4/+0
| | | | modules and objects.
* Fix a copy&paste typo.Marc-André Lemburg2004-07-101-1/+1
|
* .encode()/.decode() patch part 2.Marc-André Lemburg2004-07-081-0/+10
|
* Allow string and unicode return types from .encode()/.decode()Marc-André Lemburg2004-07-081-5/+95
| | | | | methods on string and unicode objects. Added unicode.decode() which was missing for no apparent reason.
* Fixed end-of-loop code not reached warning when using SunPro CNicholas Bastin2004-06-171-0/+4
|
* - SF #962502: Add two more methods for unicode type; width() andHye-Shik Chang2004-06-021-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)
* SF Patch #926375: Remove a useless UTF-16 support code that is neverHye-Shik Chang2004-04-061-18/+3
| | | | been used. (Suggested by Martin v. Loewis)
* Fix reallocation bug in unicode.translate(): The code was comparingWalter Dörwald2004-02-051-1/+1
| | | | characters instead of character pointers to determine space requirements.
* Cosmetic fix for wrongly indented tabs with ts=4.Hye-Shik Chang2004-01-031-8/+8
|
* Fix unicode.rsplit()'s bug that ignores separater on the end of string whenHye-Shik Chang2003-12-231-1/+1
| | | | using specialized splitter for 1 char sep.
* Fix broken xmlcharrefreplace by rev 2.204.Hye-Shik Chang2003-12-221-3/+3
| | | | (Pointy hat goes to perky)
* SF #859573: Reduce compiler warnings on gcc 3.2 and above.Hye-Shik Chang2003-12-191-1/+14
|
* Add rsplit method for str and unicode builtin types.Hye-Shik Chang2003-12-151-1/+191
| | | | | SF feature request #801847. Original patch is written by Sean Reifschneider.
* - Removed FutureWarnings related to hex/oct literals and conversionsGuido van Rossum2003-11-291-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.
* Add optional fillchar argument to ljust(), rjust(), and center() string methods.Raymond Hettinger2003-11-261-13/+45
|
* Fix a bug in the memory reallocation code of PyUnicode_TranslateCharmap().Walter Dörwald2003-10-241-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.
* Patch #825679: Clarify semantics of .isfoo on empty strings.Martin v. Löwis2003-10-181-10/+11
| | | | Backported to 2.3.
* Fix for SF bug [ 817156 ] invalid \U escape gives 0=length unistr.Jeremy Hylton2003-10-061-1/+1
|
* On c.l.py, Martin v. Löwis said that Py_UNICODE could be of a signed type,Tim Peters2003-09-161-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).
* Double-fix of crash in Unicode freelist handling.Jeremy Hylton2003-09-161-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.
* Change checks of PyUnicode_Resize() return value for clarity.Jeremy Hylton2003-09-161-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.
* SF bug #795506: Wrong handling of string format code for float values.Raymond Hettinger2003-08-271-0/+3
| | | | | | Adding missing support for '%F'. Will backport to 2.3.1.
* Fix refcounting leak in charmaptranslate_lookup()Walter Dörwald2003-08-151-0/+1
|
* Fix another refcounting leak in PyUnicode_EncodeCharmap().Walter Dörwald2003-08-151-1/+3
|
* Fix another refcounting leak (in PyUnicode_DecodeUnicodeEscape()).Walter Dörwald2003-08-151-0/+2
|
* Fix refcount leak in PyUnicode_EncodeCharmap(). The bug surfacesWalter Dörwald2003-08-141-3/+3
| | | | | | | | | | when an encoding error occurs and the callback name is unknown, i.e. when the callback has to be called. The problem was that the fact that the callback has already been looked up was only recorded in a local variable in charmap_encoding_error(), because charmap_encoding_error() got it's own copy of the errorHandler pointer instead of a pointer to the pointer in PyUnicode_EncodeCharmap().
* Support 'mbcs' as a 'built-in' encoding, so the C API can use it withoutMark Hammond2003-07-011-0/+19
| | | | | defering to the encodings package. As described in [ 763111 ] mbcs encoding should skip encodings package
* SF patch 703666: Several objects don't decref tmp on failure in subtype_newRaymond Hettinger2003-06-281-1/+4
| | | | | | Submitted By: Christopher A. Craig Fillin some missing decrefs.
* Consider \U-escapes in raw-unicode-escape. Fixes #444514.Martin v. Löwis2003-05-181-3/+42
|
* Attempt to make all the various string *strip methods the same.Neal Norwitz2003-04-101-9/+9
| | | | | | | | | | | * Doc - add doc for when functions were added * UserString * string object methods * string module functions 'chars' is used for the last parameter everywhere. These changes will be backported, since part of the changes have already been made, but they were inconsistent.
* Reformat a few docstrings that caused line wraps in help() output.Guido van Rossum2003-04-091-6/+6
|
* Change formatchar(), so that u"%c" % 0xffffffff now raisesWalter Dörwald2003-04-021-2/+2
| | | | | an OverflowError instead of a TypeError to be consistent with "%c" % 256. See SF patch #710127.
* Sf patch #700047: unicode object leaks refcount on resizingRaymond Hettinger2003-03-091-0/+1
| | | | Contributed by Hye-Shik Chang.
* Add more missing PyErr_NoMemory() after failled memory allocsNeal Norwitz2003-02-111-1/+1
|
* Fix two refcounting bugsWalter Dörwald2003-02-091-2/+4
|
* Change the treatment of positions returned by PEP293Walter Dörwald2003-01-311-9/+17
| | | | | | | | | | | | | | | | error handers in the Unicode codecs: Negative positions are treated as being relative to the end of the input and out of bounds positions result in an IndexError. Also update the PEP and include an explanation of this in the documentation for codecs.register_error. Fixes a small bug in iconv_codecs: if the position from the callback is negative *add* it to the size instead of substracting it. From SF patch #677429.
* Implement appropriate __getnewargs__ for all immutable subclassable builtinGuido van Rossum2003-01-291-0/+9
| | | | | | | | types. The special handling for these can now be removed from save_newobj(). Add some testing for this. Also add support for setting the 'fast' flag on the Python Pickler class, which suppresses use of the memo.
* Fix charmapencode_lookup(), so that a None value in the mappingWalter Dörwald2003-01-081-0/+2
| | | | | is treated as "character maps to <undefined>" and not as "character mapping must return integer, None or str".
* Remove variable owned from PyUnicode_FromEncodedObject, which is unusedWalter Dörwald2003-01-081-7/+0
| | | | (except for Py_DECREF calls) since the introduction of __unicode__.
* Patch for bug #659709: bogus computation of float lengthMarc-André Lemburg2002-12-291-10/+21
| | | | | Python 2.2.x backport candidate. (This bug has been around since Python 1.6.)
* Add nb_remainder (i.e. __mod__) slot to unicode type. Fixes SF bug #615506.Neil Schemenauer2002-11-181-2/+21
|
* Fix SF # 635969, No error "not all arguments converted"Neal Norwitz2002-11-121-1/+2
| | | | | | | | | When mwh added extended slicing, strings and unicode became mappings. Thus, dict was set which prevented an error when doing: newstr = 'format without a percent' % string_value This fix raises an exception again when there are no formats and % with a string value.
* Fix for bug #626172: crash using unicode latin1 single charMarc-André Lemburg2002-10-231-3/+1
| | | | Python 2.2.3 candidate.