summaryrefslogtreecommitdiff
path: root/Objects/stringobject.c
AgeCommit message (Collapse)AuthorLines
2009-03-29Merged revisions 70682 via svnmerge fromMark Dickinson-1/+10
svn+ssh://pythondev@svn.python.org/python/trunk ........ r70682 | mark.dickinson | 2009-03-29 17:17:16 +0100 (Sun, 29 Mar 2009) | 3 lines Issue #532631: Add paranoid check to avoid potential buffer overflow on systems with sizeof(int) > 4. ........
2009-03-29Merged revisions 70678 via svnmerge fromMark Dickinson-1/+1
svn+ssh://pythondev@svn.python.org/python/trunk ........ r70678 | mark.dickinson | 2009-03-29 15:37:51 +0100 (Sun, 29 Mar 2009) | 3 lines Issue #532631: Replace confusing fabs(x)/1e25 >= 1e25 test with fabs(x) >= 1e50, and fix documentation. ........
2008-10-04Merged revisions ↵Benjamin Peterson-7/+7
66766-66767,66771-66772,66774,66776,66783-66787,66790,66793,66797 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ................ r66766 | benjamin.peterson | 2008-10-03 06:52:06 -0500 (Fri, 03 Oct 2008) | 1 line update the mac installer script ................ r66767 | andrew.kuchling | 2008-10-03 07:26:42 -0500 (Fri, 03 Oct 2008) | 1 line Docstring typo. ................ r66771 | hirokazu.yamamoto | 2008-10-03 11:18:42 -0500 (Fri, 03 Oct 2008) | 2 lines Fixed following error when DocXMLRPCServer failed. UnboundLocalError: local variable 'serv' referenced before assignment ................ r66772 | andrew.kuchling | 2008-10-03 11:29:19 -0500 (Fri, 03 Oct 2008) | 1 line Mention exception in docstring ................ r66774 | andrew.kuchling | 2008-10-03 11:42:52 -0500 (Fri, 03 Oct 2008) | 1 line Typo fix ................ r66776 | hirokazu.yamamoto | 2008-10-03 12:34:49 -0500 (Fri, 03 Oct 2008) | 2 lines Issue #1706863: Fixed "'NoneType' object has no attribute 'rfind'" error when sqlite libfile not found. ................ r66783 | andrew.kuchling | 2008-10-03 20:02:29 -0500 (Fri, 03 Oct 2008) | 1 line Use correct capitalization of NaN ................ r66784 | andrew.kuchling | 2008-10-03 20:03:42 -0500 (Fri, 03 Oct 2008) | 1 line Docstring change: Specify exception raised ................ r66785 | andrew.kuchling | 2008-10-03 20:04:24 -0500 (Fri, 03 Oct 2008) | 1 line Docstring changes: Specify exceptions raised ................ r66786 | andrew.kuchling | 2008-10-03 20:05:56 -0500 (Fri, 03 Oct 2008) | 3 lines Docstring change for *partition: use same tense as other docstrings. Hyphenate left- and right-justified. Fix 'registerd' typo ................ r66787 | andrew.kuchling | 2008-10-03 22:08:56 -0500 (Fri, 03 Oct 2008) | 1 line two corrections ................ r66790 | andrew.kuchling | 2008-10-04 11:52:01 -0500 (Sat, 04 Oct 2008) | 1 line Set svn:keywords ................ r66793 | georg.brandl | 2008-10-04 13:26:01 -0500 (Sat, 04 Oct 2008) | 2 lines #4041: don't refer to removed and outdated modules. ................ r66797 | benjamin.peterson | 2008-10-04 15:55:50 -0500 (Sat, 04 Oct 2008) | 19 lines Merged revisions 66707,66775,66782 via svnmerge from svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r66707 | benjamin.peterson | 2008-09-30 18:27:10 -0500 (Tue, 30 Sep 2008) | 1 line fix #4001: fix_imports didn't check for __init__.py before converting to relative imports ........ r66775 | collin.winter | 2008-10-03 12:08:26 -0500 (Fri, 03 Oct 2008) | 4 lines Add an alternative iterative pattern matching system that, while slower, correctly parses files that cause the faster recursive pattern matcher to fail with a recursion error. lib2to3 falls back to the iterative matcher if the recursive one fails. Fixes http://bugs.python.org/issue2532. Thanks to Nick Edds. ........ r66782 | benjamin.peterson | 2008-10-03 17:51:36 -0500 (Fri, 03 Oct 2008) | 1 line add Victor Stinner's fixer for os.getcwdu -> os.getcwd #4023 ........ ................
2008-09-01Issue #3751: str.rpartition would perform a left-partition when called withAmaury Forgeot d'Arc-1/+1
a unicode argument. will backport.
2008-08-12Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,Martin v. Löwis-3/+4
by denying s# to parse objects that have a releasebuffer procedure, and introducing s*. More module might need to get converted to use s*.
2008-08-02Preemptively backport the relevant parts of r65420Antoine Pitrou-1/+1
2008-07-31Security patches from Apple: prevent int overflow when allocating memoryNeal Norwitz-2/+17
2008-07-17Backed out r65069, pending fixing it in Windows.Eric Smith-8/+5
2008-07-17Issue 3382: Make '%F' and float.__format__('F') convert results to upper case.Eric Smith-5/+8
2008-06-10Rename bytesobject.c back to stringobject.c to keep with the PyString theme.Gregory P. Smith-0/+5215
Part of reverting most of r63675 per the mailing list discussion.
2008-05-26Renamed bytesobject.c to bytearrayobject.cChristian Heimes-5176/+0
Renamed stringobject.c to bytesobject.c Fixed Windows builds
2008-05-26Renamed PyString to PyBytesChristian Heimes-481/+481
2008-05-26First step of the C API rename:Christian Heimes-2/+2
renamed Include/bytesobject.h to Include/bytearrayobject.h renamed Include/stringobject.h to Include/bytesobject.h added Include/stringobject.h with aliases
2008-05-11#2809 followup: even better split docstring.Georg Brandl-2/+2
2008-05-11Addresses issue 2802: 'n' formatting for integers.Eric Smith-0/+4
Adds 'n' as a format specifier for integers, to mirror the same specifier which is already available for floats. 'n' is the same as 'd', but inserts the current locale-specific thousands grouping. I added this as a stringlib function, but it's only used by str type, not unicode. This is because of an implementation detail in unicode.format(), which does its own str->unicode conversion. But the unicode version will be needed in 3.0, and it may be needed by other code eventually in 2.6 (maybe decimal?), so I left it as a stringlib implementation. As long as the unicode version isn't instantiated, there's no overhead for this.
2008-05-11#2809: elaborate str.split docstring a bit.Georg Brandl-1/+2
2008-04-10get rid of assert (size >= 0) now that an explicit if (size < 0) is in the code.Gregory P. Smith-1/+0
2008-04-09Raise SystemError when size < 0 is passed into PyString_FromStringAndSize,Gregory P. Smith-0/+5
PyBytes_FromStringAndSize or PyUnicode_FromStringAndSize. [issue2587]
2008-03-26Merged revisions ↵Christian Heimes-1/+13
61750,61752,61754,61756,61760,61763,61768,61772,61775,61805,61809,61812,61819,61917,61920,61930,61933-61934 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray ........ r61750 | christian.heimes | 2008-03-22 20:47:44 +0100 (Sat, 22 Mar 2008) | 1 line Copied files from py3k w/o modifications ........ r61752 | christian.heimes | 2008-03-22 20:53:20 +0100 (Sat, 22 Mar 2008) | 7 lines Take One * Added initialization code, warnings, flags etc. to the appropriate places * Added new buffer interface to string type * Modified tests * Modified Makefile.pre.in to compile the new files * Added bytesobject.c to Python.h ........ r61754 | christian.heimes | 2008-03-22 21:22:19 +0100 (Sat, 22 Mar 2008) | 2 lines Disabled bytearray.extend for now since it causes an infinite recursion Fixed serveral unit tests ........ r61756 | christian.heimes | 2008-03-22 21:43:38 +0100 (Sat, 22 Mar 2008) | 5 lines Added PyBytes support to several places: str + bytearray ord(bytearray) bytearray(str, encoding) ........ r61760 | christian.heimes | 2008-03-22 21:56:32 +0100 (Sat, 22 Mar 2008) | 1 line Fixed more unit tests related to type('') is not unicode ........ r61763 | christian.heimes | 2008-03-22 22:20:28 +0100 (Sat, 22 Mar 2008) | 2 lines Fixed more unit tests Fixed bytearray.extend ........ r61768 | christian.heimes | 2008-03-22 22:40:50 +0100 (Sat, 22 Mar 2008) | 1 line Implemented old buffer interface for bytearray ........ r61772 | christian.heimes | 2008-03-22 23:24:52 +0100 (Sat, 22 Mar 2008) | 1 line Added backport of the io module ........ r61775 | christian.heimes | 2008-03-23 03:50:49 +0100 (Sun, 23 Mar 2008) | 1 line Fix str assignement to bytearray. Assignment of a str of size 1 is interpreted as a single byte ........ r61805 | christian.heimes | 2008-03-23 19:33:48 +0100 (Sun, 23 Mar 2008) | 3 lines Fixed more tests Fixed bytearray() comparsion with unicode() Fixed iterator assignment of bytearray ........ r61809 | christian.heimes | 2008-03-23 21:02:21 +0100 (Sun, 23 Mar 2008) | 2 lines str(bytesarray()) now returns the bytes and not the representation of the bytearray object Enabled and fixed more unit tests ........ r61812 | christian.heimes | 2008-03-23 21:53:08 +0100 (Sun, 23 Mar 2008) | 3 lines Clear error PyNumber_AsSsize_t() fails Use CHARMASK for ob_svall access disabled a test with memoryview again ........ r61819 | christian.heimes | 2008-03-23 23:05:57 +0100 (Sun, 23 Mar 2008) | 1 line Untested updates to the PCBuild directory ........ r61917 | christian.heimes | 2008-03-26 00:57:06 +0100 (Wed, 26 Mar 2008) | 1 line The type system of Python 2.6 has subtle differences to 3.0's. I've removed the Py_TPFLAGS_BASETYPE flags from bytearray for now. bytearray can't be subclasses until the issues with bytearray subclasses are fixed. ........ r61920 | christian.heimes | 2008-03-26 01:44:08 +0100 (Wed, 26 Mar 2008) | 2 lines Disabled last failing test I don't understand what the test is testing and how it suppose to work. Ka-Ping, please check it out. ........ r61930 | christian.heimes | 2008-03-26 12:46:18 +0100 (Wed, 26 Mar 2008) | 1 line Re-enabled bytes warning code ........ r61933 | christian.heimes | 2008-03-26 13:20:46 +0100 (Wed, 26 Mar 2008) | 1 line Fixed a bug in the new buffer protocol. The buffer slots weren't copied into a subclass. ........ r61934 | christian.heimes | 2008-03-26 13:25:09 +0100 (Wed, 26 Mar 2008) | 1 line Re-enabled bytearray subclassing - all tests are passing. ........
2008-03-11Fix the overflows in expandtabs(). "This time for sure!"Guido van Rossum-25/+32
(Exploit at request.)
2008-02-24Issue 1742669. Now %d accepts very big float numbers.Facundo Batista-16/+46
Thanks Gabriel Genellina.
2008-02-17Backport of PEP 3101, Advanced String Formatting, from py3k.Eric Smith-9/+20
Highlights: - Adding PyObject_Format. - Adding string.Format class. - Adding __format__ for str, unicode, int, long, float, datetime. - Adding builtin format. - Adding ''.format and u''.format. - str/unicode fixups for formatters. The files in Objects/stringlib that implement PEP 3101 (stringdefs.h, unicodedefs.h, formatter.h, string_format.h) are identical in trunk and py3k. Any changes from here on should be made to trunk, and changes will propogate to py3k).
2007-12-19#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and ↵Christian Heimes-64/+64
Py_REFCNT. Macros for b/w compatibility are available.
2007-12-08When splitting, avoid making a copy of the string if the split doesn't findSkip Montanaro-11/+42
anything (issue 1538).
2007-11-16Now in find, rfind, index, and rindex, you can use None as defaults,Facundo Batista-2/+13
as usual with slicing (both with str and unicode strings). This fixes issue 1259. For str only the stringobject.c file was modified. But for unicode, I needed to repeat in the four functions a lot of code, so created a new function that does part of the job for them (and placed it in find.h, following a suggestion of Barry). Also added tests for this behaviour.
2007-11-06Add missing "return NULL" in overflow check in PyObject_Repr().Guido van Rossum-0/+1
2007-10-29Backport fixes for the code that decodes octal escapes (and for PyStringGuido van Rossum-4/+6
also hex escapes) -- this was reaching beyond the end of the input string buffer, even though it is not supposed to be \0-terminated. This has no visible effect but is clearly the correct thing to do. (In 3.0 it had a visible effect after removing ob_sstate from PyString.)
2007-09-17Add a bunch of GIL release/acquire points in tp_print implementations and forBrett Cannon-2/+10
PyObject_Print(). Closes issue #1164.
2007-08-28Improve extended slicing support in builtin types and classes. Specifically:Thomas Wouters-0/+11
- Specialcase extended slices that amount to a shallow copy the same way as is done for simple slices, in the tuple, string and unicode case. - Specialcase step-1 extended slices to optimize the common case for all involved types. - For lists, allow extended slice assignment of differing lengths as long as the step is 1. (Previously, 'l[:2:1] = []' failed even though 'l[:2] = []' and 'l[:2:None] = []' do not.) - Implement extended slicing for buffer, array, structseq, mmap and UserString.UserString. - Implement slice-object support (but not non-step-1 slice assignment) for UserString.MutableString. - Add tests for all new functionality.
2007-07-29Bug #1763149: use proper slice syntax in docstring.Georg Brandl-2/+2
(backport)
2007-07-21PEP 3123: Provide forward compatibility with Python 3.0, while keepingMartin v. Löwis-68/+66
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
2007-07-12Patch #1673759: add a missing overflow check when formatting floatsGeorg Brandl-1/+2
with %G.
2007-06-11Fix a bug when there was a newline in the string expandtabs was called on.Neal Norwitz-2/+8
This also catches another condition that can overflow. Will backport.
2007-06-09Prevent expandtabs() on string and unicode objects from causing a segfault whenNeal Norwitz-3/+14
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-04-12SF 1193128: Let str.translate(None) be an identity transformationRaymond Hettinger-8/+16
2007-02-26Backport from Py3k branch: fix refleak in PyString_Format.Georg Brandl-1/+5
2007-02-25Variation of patch # 1624059 to speed up checking if an object is a subclassNeal Norwitz-1/+1
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.
2007-02-25Whitespace only changesNeal Norwitz-3/+2
2007-02-25Add more details when releasing interned stringsNeal Norwitz-1/+8
2006-11-19Patch [ 1586791 ] better error msgs for some TypeErrorsGeorg Brandl-6/+10
2006-10-04Forward-port of r52136,52138: a review of overflow-detecting code.Armin Rigo-6/+19
* 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. * 2.5 specific: fixed a number of places that were still confusing int and Py_ssize_t. Some of them could potentially have caused "real-world" breakage. * list.pop(x): fixing overflow issues on x was messy. I just reverted to PyArg_ParseTuple("n"), which does the right thing. (An obscure test was trying to give a Decimal to list.pop()... doesn't make sense any more IMHO) * trying to write a few tests...
2006-09-04Fix endcase for str.rpartition()Raymond Hettinger-2/+2
2006-08-14Fix refleak introduced in rev. 51248.Georg Brandl-1/+3
2006-08-13Fix segfault when doing string formatting on subclasses of long ifNeal Norwitz-1/+4
__oct__, __hex__ don't return a string. Klocwork 308
2006-08-12Patch #1538606, Patch to fix __index__() clipping.Neal Norwitz-5/+2
I modified this patch some by fixing style, some error checking, and adding XXX comments. This patch requires review and some changes are to be expected. I'm checking in now to get the greatest possible review and establish a baseline for moving forward. I don't want this to hold up release if possible.
2006-07-30Whitespace normalizationNeal Norwitz-35/+32
2006-07-30Bug #1515471: string.replace() accepts character buffers again.Neal Norwitz-71/+51
Pass the char* and size around rather than PyObject's.
2006-06-11Update doc to make it agree with code.Neal Norwitz-10/+4
Bottom factor out some common code.
2006-06-10Apply perky's fix for #1503157: "/".join([u"", u""]) raising OverflowError.Georg Brandl-1/+1
Also improve error message on overflow.
2006-06-09RFE #1491485: str/unicode.endswith()/startswith() now accept a tuple as ↵Georg Brandl-60/+90
first argument.