summaryrefslogtreecommitdiffstats
path: root/Include/stringobject.h
Commit message (Collapse)AuthorAgeFilesLines
* Merging the py3k-pep3137 branch back into the py3k branch.Guido van Rossum2007-11-061-78/+9
| | | | | | | | | | | | | | No detailed change log; just check out the change log for the py3k-pep3137 branch. The most obvious changes: - str8 renamed to bytes (PyString at the C level); - bytes renamed to buffer (PyBytes at the C level); - PyString and PyUnicode are no longer compatible. I.e. we now have an immutable bytes type and a mutable bytes type. The behavior of PyString was modified quite a bit, to make it more bytes-like. Some changes are still on the to-do list.
* Kill PyString_Encode(), which isn't used anywhere.Guido van Rossum2007-10-261-18/+8
| | | | | (We should also kill the other PyString_ encode/decode APIs, but they still have some users.)
* Patch# 1258 by Christian Heimes: kill basestring.Guido van Rossum2007-10-161-1/+0
| | | | I like this because it makes the code shorter! :-)
* Fix merge breakage.Martin v. Löwis2007-07-211-1/+1
|
* Merged revisions 56467-56482 via svnmerge fromMartin v. Löwis2007-07-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/p3yk ................ r56477 | martin.v.loewis | 2007-07-21 09:04:38 +0200 (Sa, 21 Jul 2007) | 11 lines Merged revisions 56466-56476 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r56476 | martin.v.loewis | 2007-07-21 08:55:02 +0200 (Sa, 21 Jul 2007) | 4 lines PEP 3123: Provide forward compatibility with Python 3.0, while keeping backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT. ........ ................ r56478 | martin.v.loewis | 2007-07-21 09:47:23 +0200 (Sa, 21 Jul 2007) | 2 lines PEP 3123: Use proper C inheritance for PyObject. ................ r56479 | martin.v.loewis | 2007-07-21 10:06:55 +0200 (Sa, 21 Jul 2007) | 3 lines Add longintrepr.h to Python.h, so that the compiler can see that PyFalse is really some kind of PyObject*. ................ r56480 | martin.v.loewis | 2007-07-21 10:47:18 +0200 (Sa, 21 Jul 2007) | 2 lines Qualify SHIFT, MASK, BASE. ................ r56482 | martin.v.loewis | 2007-07-21 19:10:57 +0200 (Sa, 21 Jul 2007) | 2 lines Correctly refer to _ob_next. ................
* Make identifiers str (not str8) objects throughout.Martin v. Löwis2007-06-101-2/+2
| | | | | | | | | | | | | | | | | | | This affects the parser, various object implementations, and all places that put identifiers into C string literals. In testing, a number of crashes occurred as code would fail when the recursion limit was reached (such as the Unicode interning dictionary having key/value pairs where key is not value). To solve these, I added an overflowed flag, which allows for 50 more recursions after the limit was reached and the exception was raised, and a recursion_critical flag, which indicates that recursion absolutely must be allowed, i.e. that a certain call must not cause a stack overflow exception. There are still some places where both str and str8 are accepted as identifiers; these should eventually be removed.
* Add interning of unicode strings by copying the functionality fromWalter Dörwald2007-05-251-4/+0
| | | | | | | stringobject.c. Intern "True" and "False" in bool_repr() again as it was in the 8bit string era.
* Merged revisions 53875-53911 via svnmerge fromThomas Wouters2007-02-251-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r53899 | neal.norwitz | 2007-02-25 16:52:27 +0100 (Sun, 25 Feb 2007) | 1 line Add more details when releasing interned strings ........ r53900 | neal.norwitz | 2007-02-25 16:53:36 +0100 (Sun, 25 Feb 2007) | 1 line Whitespace only changes ........ r53901 | jeremy.hylton | 2007-02-25 16:57:45 +0100 (Sun, 25 Feb 2007) | 8 lines Fix crash in exec when unicode filename can't be decoded. I can't think of an easy way to test this behavior. It only occurs when the file system default encoding and the interpreter default encoding are different, such that you can open the file but not decode its name. ........ r53902 | jeremy.hylton | 2007-02-25 17:01:58 +0100 (Sun, 25 Feb 2007) | 2 lines Put declarations before code. ........ r53910 | fred.drake | 2007-02-25 18:56:27 +0100 (Sun, 25 Feb 2007) | 3 lines - SF patch #1657613: add documentation for the Element interface - clean up bogus use of the {datadescni} environment everywhere ........ r53911 | neal.norwitz | 2007-02-25 20:44:48 +0100 (Sun, 25 Feb 2007) | 17 lines Variation of patch # 1624059 to speed up checking if an object is a subclass of some of the common builtin types. Use a bit in tp_flags for each common builtin type. Check the bit to determine if any instance is a subclass of these common types. The check avoids a function call and O(n) search of the base classes. The check is done in the various Py*_Check macros rather than calling PyType_IsSubtype(). All the bits are set in tp_flags when the type is declared in the Objects/*object.c files because PyType_Ready() is not called for all the types. Should PyType_Ready() be called for all types? If so and the change is made, the changes to the Objects/*object.c files can be reverted (remove setting the tp_flags). Objects/typeobject.c would also have to be modified to add conditions for Py*_CheckExact() in addition to each the PyType_IsSubtype check. ........
* Patch #1601678: move intern() to sys.intern().Georg Brandl2006-12-191-1/+1
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-8/+8
|
* Wrote down the invariants of some common objects whose structure isArmin Rigo2004-10-281-0/+9
| | | | | | | | | | exposed in header files. Fixed a few comments in these headers. As we might have expected, writing down invariants systematically exposed a (minor) bug. In this case, function objects have a writeable func_code attribute, which could be set to code objects with the wrong number of free variables. Calling the resulting function segfaulted the interpreter. Added a corresponding test.
* Use appropriate macros not the deprecated DL_IMPORT/DL_EXPORT macrosNeal Norwitz2003-07-011-1/+1
|
* Use Py_GCC_ATTRIBUTE instead of __attribute__. Compilers other than GCCNeil Schemenauer2002-09-151-2/+2
| | | | might use __attribute__ in other ways (e.g. CodeWarrior).
* SF patch 576101, by Oren Tirosh: alternative implementation ofGuido van Rossum2002-08-191-2/+10
| | | | | | | | interning. I modified Oren's patch significantly, but the basic idea and most of the implementation is unchanged. Interned strings created with PyString_InternInPlace() are now mortal, and you must keep a reference to the resulting string around; use the new function PyString_InternImmortal() to create immortal interned strings.
* Patch #505705: Remove eval in pickle and cPickle.Martin v. Löwis2002-08-141-0/+4
|
* Excise DL_EXPORT from Include.Mark Hammond2002-08-121-25/+25
| | | | Thanks to Skip Montanaro and Kalle Svensson for the patches.
* - A new type object, 'string', is added. This is a common base typeGuido van Rossum2002-05-241-0/+1
| | | | | | | for 'str' and 'unicode', and can be used instead of types.StringTypes, e.g. to test whether something is "a string": isinstance(x, string) is True for Unicode and 8-bit strings. This is an abstract base class and cannot be instantiated directly.
* Remove the CACHE_HASH and INTERN_STRINGS preprocessor symbols.Tim Peters2002-03-291-23/+7
|
* Add function attributes that allow GCC to check the arguments of printf-likeNeil Schemenauer2001-10-231-2/+4
| | | | functions.
* More on SF bug [#460020] bug or feature: unicode() and subclasses.Tim Peters2001-09-111-0/+1
| | | | | Repaired str(i) to return a genuine string when i is an instance of a str subclass. New PyString_CheckExact() macro.
* Make the Py<type>_Check() macro use PyObject_TypeCheck().Guido van Rossum2001-08-301-1/+1
|
* PyString_FromFormat() and PyString_FromFormatV(): Largely ripped fromBarry Warsaw2001-08-241-0/+4
| | | | | | | | | | | | | | | | | | | PyErr_Format() these new C API methods can be used instead of sprintf()'s into hardcoded char* buffers. This allows us to fix many situation where long package, module, or class names get truncated in reprs. PyString_FromFormat() is the varargs variety. PyString_FromFormatV() is the va_list variety Original PyErr_Format() code was modified to allow %p and %ld expansions. Many reprs were converted to this, checkins coming soo. Not changed: complex_repr(), float_repr(), float_print(), float_str(), int_repr(). There may be other candidates not yet converted. Closes patch #454743.
* SF bug 433228: repr(list) woes when len(list) big.Tim Peters2001-06-161-0/+4
| | | | | | | | | | | | Gave Python linear-time repr() implementations for dicts, lists, strings. This means, e.g., that repr(range(50000)) is no longer 50x slower than pprint.pprint() in 2.2 <wink>. I don't consider this a bugfix candidate, as it's a performance boost. Added _PyString_Join() to the internal string API. If we want that in the public API, fine, but then it requires runtime error checks instead of asserts.
* Patch #424335: Implement string_richcompare, remove string_compare.Martin v. Löwis2001-05-241-0/+1
| | | | Use new _PyString_Eq in lookdict_string.
* This patch changes the way the string .encode() method works slightlyMarc-André Lemburg2001-05-151-3/+40
| | | | | | | | | | | | | | | | | | | | | | | | | and introduces a new method .decode(). The major change is that strg.encode() will no longer try to convert Unicode returns from the codec into a string, but instead pass along the Unicode object as-is. The same is now true for all other codec return types. The underlying C APIs were changed accordingly. Note that even though this does have the potential of breaking existing code, the chances are low since conversion from Unicode previously took place using the default encoding which is normally set to ASCII rendering this auto-conversion mechanism useless for most Unicode encodings. The good news is that you can now use .encode() and .decode() with much greater ease and that the door was opened for better accessibility of the builtin codecs. As demonstration of the new feature, the patch includes a few new codecs which allow string to string encoding and decoding (rot13, hex, zip, uu, base64). Written by Marc-Andre Lemburg. Copyright assigned to the PSF.
* _Py_ReleaseInternedStrings(): Private API function to decref andBarry Warsaw2001-02-231-0/+2
| | | | | | release the interned string dictionary. This is useful for memory use debugging because it eliminates a huge source of noise from the reports. Only defined when INTERN_STRINGS is defined.
* Derived from Martin's SF patch 110609: support unbounded ints in ↵Tim Peters2000-09-211-0/+2
| | | | | | | | | | | | | | | | %d,i,u,x,X,o formats. Note a curious extension to the std C rules: x, X and o formatting can never produce a sign character in C, so the '+' and ' ' flags are meaningless for them. But unbounded ints *can* produce a sign character under these conversions (no fixed- width bitstring is wide enough to hold all negative values in 2's-comp form). So these flags become meaningful in Python when formatting a Python long which is too big to fit in a C long. This required shuffling around existing code, which hacked x and X conversions to death when both the '#' and '0' flags were specified: the hacks weren't strong enough to deal with the simultaneous possibility of the ' ' or '+' flags too, since signs were always meaningless before for x and X conversions. Isomorphic shuffling was required in unicodeobject.c. Also added dozens of non-trivial new unbounded-int test cases to test_format.py.
* This patch adds a new Python C API called PyString_AsStringAndSize()Marc-André Lemburg2000-09-191-0/+15
| | | | | | | | | | | | | which implements the automatic conversion from Unicode to a string object using the default encoding. The new API is then put to use to have eval() and exec accept Unicode objects as code parameter. This closes bugs #110924 and #113890. As side-effect, the traditional C APIs PyString_Size() and PyString_AsString() will also accept Unicode objects as parameters.
* REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum2000-09-011-9/+0
| | | | This should match the situation in the 1.6b1 tree.
* ANSI-fication and Py_PROTO extermination.Fred Drake2000-07-091-20/+20
|
* Added prototypes for the new codec APIs for strings. These APIsMarc-André Lemburg2000-07-061-0/+31
| | | | | | | | | match the ones in the Unicode implementation, but were extended to be able to reuse the existing Unicode codecs for string purposes too. Conversion from string to Unicode and back are done using the default encoding.
* Change copyright notice - 2nd try.Guido van Rossum2000-06-301-6/+0
|
* Change copyright notice.Guido van Rossum2000-06-301-22/+7
|
* Add DL_IMPORT(returntype) for all officially exported functions.Guido van Rossum1998-12-041-10/+10
|
* Two speedup hacks. Caching the hash saves recalculation of a string'sGuido van Rossum1997-01-181-3/+23
| | | | | | | | | | hash value. Interning strings (which requires hash caching) tries to ensure that only one string object with a given value exists, so equality tests are one pointer comparison. Together, these can speed the interpreter up by as much as 20%. Each costs the size of a long or pointer per string object. In addition, interned strings live until the end of times. If you are concerned about memory footprint, simply comment the #define out here (and rebuild everything!).
* added PyString_GET_SIZE macroBarry Warsaw1997-01-061-1/+2
| | | | | for both PyString_GET_SIZE and PyString_AS_STRING, cast first argument to a PyStringObject*
* Add const to error and newstring functionsGuido van Rossum1996-12-101-2/+2
|
* New permission notice, includes CNRI.Guido van Rossum1996-10-251-13/+20
|
* Turn on CACHE_HASH, for 2% speedier dict lookupsGuido van Rossum1996-07-301-0/+3
|
* make the type a parameter of the DL_IMPORT macro, for Borland CGuido van Rossum1995-02-271-1/+1
|
* new names for lots of new functionsGuido van Rossum1995-01-171-3/+1
|
* The great renaming, phase two: all header files have been updated toGuido van Rossum1995-01-121-14/+14
| | | | | | | use the new names exclusively, and the linker will see the new names. Files that import "Python.h" also only see the new names. Files that import "allobjects.h" will continue to be able to use the old names, due to the inclusion (in allobjects.h) of "rename2.h".
* Added 1995 copyright.Guido van Rossum1995-01-041-3/+3
| | | | | | object.h: made sizes and refcnts signed ints. stringobject.h: make getstrsize() signed int. methodobject.h: add METH_VARARGS and METH_FREENAME flag bit definitions.
* Changes for dynamic linking under NTGuido van Rossum1994-08-181-1/+1
|
* Merge alpha100 branch back to main trunkGuido van Rossum1994-08-011-1/+2
|
* Several optimizations and speed improvements.Sjoerd Mullender1993-10-221-0/+3
| | | | cstubs: Use Matrix type instead of float[4][4].
* * Added support for X11 modules.Guido van Rossum1993-07-281-0/+11
| | | | | | | * Makefile: change location of FORMS library. * posixmodule.c: turn #if 0 into #ifdef MSDOS (stuff in unistd.h or not) * Almost all .h files: added CPP magic to avoid duplicate inclusions and to support inclusion from C++.
* * Changed many files to use mkvalue() instead of newtupleobject().Guido van Rossum1993-03-161-2/+3
| | | | | | | | | | * Fixcprt.py: added [-y file] option, do only files younger than file. * modsupport.[ch]: added vmkvalue(). * intobject.c: use mkvalue(). * stringobject.c: added "formatstring"; renamed string* to string_*; ceval.c: call formatstring for string % value. * longobject.c: close memory leak in divmod. * parsetok.c: set result node to NULL when returning an error.
* Copyright for 1992 addedGuido van Rossum1992-04-051-1/+1
|
* Added copyright notice.Guido van Rossum1991-02-191-0/+24
|