summaryrefslogtreecommitdiff
path: root/Lib/string.py
AgeCommit message (Collapse)AuthorLines
2018-01-04bpo-31672: Restore the former behavior when override flags in Template. (#5099)Serhiy Storchaka-4/+1
Overriding flags to 0 will make the default pattern matching only lower case letters.
2017-11-21bpo-31672 - Add one last minor clarification for idpattern (#4483)Barry Warsaw-4/+7
Add one last minor clarification for idpattern
2017-10-13bpo-31672: Fix string.Template accidentally matched non-ASCII identifiers ↵INADA Naoki-1/+5
(GH-3872) Pattern `[a-z]` with `IGNORECASE` flag can match to some non-ASCII characters. Straightforward solution for this is using `IGNORECASE | ASCII` flag. But users may subclass `Template` and override only `idpattern`. So we want to avoid changing `Template.flags`. So this commit uses local flag `-i` for `idpattern` and change `[a-z]` to `[a-zA-Z]`.
2017-09-04bpo-1198569: Allow string.Template braced pattern to be different (#3288)Barry Warsaw-1/+3
* bpo-1198569: Allow the braced pattern to be different ``string.Template`` subclasses can optionally define ``braceidpattern`` if they want to specify different placeholder patterns inside and outside the braces. If None (the default) it falls back to ``idpattern``.
2017-01-13Issue #29193: A format string argument for string.Formatter.format()Serhiy Storchaka-8/+2
is now positional-only.
2016-09-08#27364: fix "incorrect" uses of escape character in the stdlib.R David Murray-1/+1
And most of the tools. Patch by Emanual Barry, reviewed by me, Serhiy Storchaka, and Martin Panter.
2016-06-04Closes #26809: Merge with 3.5Zachary Ware-3/+7
2016-06-04Issue #26809: Add __all__ to string module. Patch by Emanuel BarryZachary Ware-3/+7
2015-09-29Issue #25034: Merge from 3.5.Eric V. Smith-5/+6
2015-09-29Issue #25034: Merge from 3.4.Eric V. Smith-5/+6
2015-09-29Fixed issue #25034: Fix string.Formatter problem with auto-numberingEric V. Smith-5/+6
and nested format_specs. Patch by Anthon van der Neut.
2015-05-30Reverting my previous commit.Yury Selivanov-2/+7
Something went horribly wrong when I was doing `hg rebase`.
2015-05-28Issue #24309: Removed Python 2 idioms.Serhiy Storchaka-7/+2
2015-03-24Issue #23671: string.Template now allows to specify the "self" parameter asSerhiy Storchaka-3/+26
keyword argument. string.Formatter now allows to specify the "self" and the "format_string" parameters as keyword arguments.
2015-03-24Issue #23671: string.Template now allows to specify the "self" parameter asSerhiy Storchaka-3/+23
keyword argument. string.Formatter now allows to specify the "self" and the "format_string" parameters as keyword arguments.
2014-04-14Issue #13598: Add auto-numbering of replacement fields to string.Formatter.Eric V. Smith-2/+21
2012-08-19Merge #13579: teach string.Formatter about 'a'.R David Murray-4/+6
Patch by Francisco Martín Brugué.
2012-08-19#13579: teach string.Formatter about 'a'.R David Murray-4/+6
Patch by Francisco Martín Brugué.
2011-09-28#13012: use splitlines(keepends=True/False) instead of splitlines(0/1).Ezio Melotti-1/+1
2011-02-26Issue #11297: Add collections.ChainMap()Raymond Hettinger-3/+3
2011-02-22Factor-out common code for helper classes.Raymond Hettinger-19/+3
2010-10-14#9418: first step of moving private string methods to _string module.Georg Brandl-4/+6
2010-09-18Issue #1686: Fix string.Template when overriding the pattern attribute.Florent Xicluna-9/+3
2010-09-06typoFlorent Xicluna-2/+2
2010-07-29#6630: allow customizing flags for compiling string.Template.idpattern.Georg Brandl-1/+2
2009-09-26Merged revisions 75070 via svnmerge fromEzio Melotti-4/+6
svn+ssh://pythondev@svn.python.org/python/trunk ........ r75070 | ezio.melotti | 2009-09-26 14:20:53 +0300 (Sat, 26 Sep 2009) | 1 line #7000: document "sep" in capwords. Add a few tests ........
2009-06-28remove string.maketransBenjamin Peterson-22/+0
2009-05-08#4351: more appropriate DeprecationWarning stacklevelsPhilip Jenvey-1/+1
2009-04-12Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecateGeorg Brandl-0/+3
string.maketrans() which actually works on bytes. (Also closes #5675.)
2008-11-22#4361: fix string.py docstring, clarify that only ASCII characters are in ↵Georg Brandl-9/+9
its constants.
2008-11-16Merged revisions 67154,67157-67159,67175-67176,67189,67224-67227,67234 via ↵Benjamin Peterson-3/+2
svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r67154 | hirokazu.yamamoto | 2008-11-07 21:46:17 -0600 (Fri, 07 Nov 2008) | 1 line Issue #4071: ntpath.abspath returned an empty string for long unicode path. ........ r67157 | georg.brandl | 2008-11-08 05:47:44 -0600 (Sat, 08 Nov 2008) | 2 lines Don't use "HOWTO" as the title for all howto .tex files. ........ r67158 | georg.brandl | 2008-11-08 05:48:20 -0600 (Sat, 08 Nov 2008) | 2 lines Update "Documenting" a bit. Concentrate on Python-specifics. ........ r67159 | georg.brandl | 2008-11-08 06:52:25 -0600 (Sat, 08 Nov 2008) | 2 lines Fix warning. ........ r67175 | benjamin.peterson | 2008-11-08 19:44:32 -0600 (Sat, 08 Nov 2008) | 1 line update link ........ r67176 | benjamin.peterson | 2008-11-08 19:52:32 -0600 (Sat, 08 Nov 2008) | 1 line fix comment ........ r67189 | benjamin.peterson | 2008-11-11 15:56:06 -0600 (Tue, 11 Nov 2008) | 1 line use correct name ........ r67224 | georg.brandl | 2008-11-15 02:10:04 -0600 (Sat, 15 Nov 2008) | 2 lines #4324: fix getlocale() argument. ........ r67225 | brett.cannon | 2008-11-15 16:33:25 -0600 (Sat, 15 Nov 2008) | 1 line Clarify the docs for the 'strict' argument to httplib.HTTPConnection. ........ r67226 | brett.cannon | 2008-11-15 16:40:44 -0600 (Sat, 15 Nov 2008) | 4 lines The docs for httplib.HTTPConnection.putheader() have claimed for quite a while that their could be an arbitrary number of values passed in. Turns out the code did not match that. The code now matches the docs. ........ r67227 | georg.brandl | 2008-11-16 02:00:17 -0600 (Sun, 16 Nov 2008) | 2 lines #4316: fix configure.in markup problem. ........ r67234 | benjamin.peterson | 2008-11-16 11:54:55 -0600 (Sun, 16 Nov 2008) | 1 line run autoconf ........
2007-11-21Rename buffer -> bytearray.Guido van Rossum-1/+1
2007-11-06Merging the py3k-pep3137 branch back into the py3k branch.Guido van Rossum-3/+3
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.
2007-09-04Changed some ValueError's to KeyError and IndexError.Eric Smith-3/+13
Corrected code for invalid conversion specifier. Added tests to verify. Modified string.Formatter to correctly expand format_spec's, and added a limit to recursion depth. Added _vformat() method to support both of these.
2007-09-02Removed used_args param from string.Formatter.get_field. It was left in by ↵Eric Smith-4/+2
mistake from an earlier edit.
2007-08-31string.maketrans() now produces translation tables for bytes.translate() -- ↵Georg Brandl-21/+14
wrong module? Fix all remaining instances that did bad things with the new str.translate().
2007-08-31Changed signature of string.Formatter.get_field, per suggestion byEric Smith-7/+5
Ron Adam. Added test case for using all parameters in string.Formatter.
2007-08-30Raise statement normalization in Lib/.Collin Winter-1/+1
2007-08-29Revert r57685 (weird merge result).Collin Winter-1/+0
2007-08-29(no commit message)Collin Winter-0/+1
2007-08-29Modified parsing of format strings, so that we always returnEric Smith-4/+13
a tuple (literal, field_name, format_spec, conversion). literal will always be a string, but might be of zero length. field_name will be None if there is no markup text format_spec will be a (possibly zero length) string if field_name is non-None conversion will be a one character string, or None This makes the Formatter class, and especially it's parse() method, easier to understand. Suggestion was by Jim Jewett, inspired by the "tail" of an elementtree node. Also, fixed a reference leak in fieldnameiter_next.
2007-08-28Simplified tuple returned by string._formatter_parser to only haveEric Smith-24/+58
4 elements. No need for old is_markup element, the same information is indicated by literal_string being None. Factored string.Formatter class to make subclasses easier to write.
2007-08-27PEP 3101: Removed _formatter_xxx routines from sysmodule, and made them ↵Eric Smith-6/+4
unicode methods instead (per GvR suggestion).
2007-08-26PEP 3101: Completed string.Formatter class. Reimplemented field_name to ↵Eric Smith-7/+35
object transformation.
2007-08-25Implementation of PEP 3101, Advanced String Formatting.Eric Smith-0/+39
Known issues: The string.Formatter class, as discussed in the PEP, is incomplete. Error handling needs to conform to the PEP. Need to fix this warning that I introduced in Python/formatter_unicode.c: Objects/stringlib/unicodedefs.h:26: warning: `STRINGLIB_CMP' defined but not used Need to make sure sign formatting is correct, more tests needed. Need to remove '()' sign formatting, left over from an earlier version of the PEP.
2007-08-14Remove string.{letters,lowercase,uppercase}.Martin v. Löwis-6/+3
2007-07-03Merged revisions 56125-56153 via svnmerge fromGuido van Rossum-7/+4
svn+ssh://pythondev@svn.python.org/python/branches/p3yk ........ r56127 | georg.brandl | 2007-06-30 09:32:49 +0200 (Sat, 30 Jun 2007) | 2 lines Fix a place where floor division would be in order. ........ r56135 | guido.van.rossum | 2007-07-01 06:13:54 +0200 (Sun, 01 Jul 2007) | 28 lines Make map() and filter() identical to itertools.imap() and .ifilter(), respectively. I fixed two bootstrap issues, due to the dynamic import of itertools: 1. Starting python requires that map() and filter() are not used until site.py has added build/lib.<arch> to sys.path. 2. Building python requires that setup.py and distutils and everything they use is free of map() and filter() calls. Beyond this, I only fixed the tests in test_builtin.py. Others, please help fixing the remaining tests that are now broken! The fixes are usually simple: a. map(None, X) -> list(X) b. map(F, X) -> list(map(F, X)) c. map(lambda x: F(x), X) -> [F(x) for x in X] d. filter(F, X) -> list(filter(F, X)) e. filter(lambda x: P(x), X) -> [x for x in X if P(x)] Someone, please also contribute a fixer for 2to3 to do this. It can leave map()/filter() calls alone that are already inside a list() or sorted() call or for-loop. Only in rare cases have I seen code that depends on map() of lists of different lengths going to the end of the longest, or on filter() of a string or tuple returning an object of the same type; these will need more thought to fix. ........ r56136 | guido.van.rossum | 2007-07-01 06:22:01 +0200 (Sun, 01 Jul 2007) | 3 lines Make it so that test_decimal fails instead of hangs, to help automated test runners. ........ r56139 | georg.brandl | 2007-07-01 18:20:58 +0200 (Sun, 01 Jul 2007) | 2 lines Fix a few test cases after the map->imap change. ........ r56142 | neal.norwitz | 2007-07-02 06:38:12 +0200 (Mon, 02 Jul 2007) | 1 line Get a bunch more tests passing after converting map/filter to return iterators. ........ r56147 | guido.van.rossum | 2007-07-02 15:32:02 +0200 (Mon, 02 Jul 2007) | 4 lines Fix the remaining failing unit tests (at least on OSX). Also tweaked urllib2 so it doesn't raise socket.gaierror when all network interfaces are turned off. ........
2007-05-17Merged revisions 55342-55406 via svnmerge fromGuido van Rossum-11/+0
svn+ssh://pythondev@svn.python.org/python/branches/p3yk ........ r55360 | guido.van.rossum | 2007-05-15 14:57:59 -0700 (Tue, 15 May 2007) | 2 lines obcheckin. ........ r55361 | guido.van.rossum | 2007-05-15 14:59:18 -0700 (Tue, 15 May 2007) | 2 lines Get rid of strop module. ........ r55367 | brett.cannon | 2007-05-15 21:06:28 -0700 (Tue, 15 May 2007) | 2 lines Remove the 'pure' module. ........ r55369 | brett.cannon | 2007-05-15 21:07:31 -0700 (Tue, 15 May 2007) | 2 lines Remove the lib-old directory (already empty). ........ r55370 | neal.norwitz | 2007-05-15 21:30:40 -0700 (Tue, 15 May 2007) | 1 line Get rid of a bunch more references to strop ........ r55374 | brett.cannon | 2007-05-15 21:39:00 -0700 (Tue, 15 May 2007) | 2 lines Complete the removal of IRIX-specific modules. ........ r55379 | brett.cannon | 2007-05-15 22:31:54 -0700 (Tue, 15 May 2007) | 2 lines Update removed IRIX modules based on what is gone from removing plat-irix6. ........ r55388 | brett.cannon | 2007-05-16 14:34:52 -0700 (Wed, 16 May 2007) | 2 lines Clean up the docstring for the compiler resource. ........ r55406 | brett.cannon | 2007-05-17 11:05:37 -0700 (Thu, 17 May 2007) | 2 lines Remove BaseException.message (deprecated in Python 2.6). ........
2007-05-07Merged revisions 55007-55179 via svnmerge fromGuido van Rossum-1/+1
svn+ssh://pythondev@svn.python.org/python/branches/p3yk ........ r55077 | guido.van.rossum | 2007-05-02 11:54:37 -0700 (Wed, 02 May 2007) | 2 lines Use the new print syntax, at least. ........ r55142 | fred.drake | 2007-05-04 21:27:30 -0700 (Fri, 04 May 2007) | 1 line remove old cruftiness ........ r55143 | fred.drake | 2007-05-04 21:52:16 -0700 (Fri, 04 May 2007) | 1 line make this work with the new Python ........ r55162 | neal.norwitz | 2007-05-06 22:29:18 -0700 (Sun, 06 May 2007) | 1 line Get asdl code gen working with Python 2.3. Should continue to work with 3.0 ........ r55164 | neal.norwitz | 2007-05-07 00:00:38 -0700 (Mon, 07 May 2007) | 1 line Verify checkins to p3yk (sic) branch go to 3000 list. ........ r55166 | neal.norwitz | 2007-05-07 00:12:35 -0700 (Mon, 07 May 2007) | 1 line Fix this test so it runs again by importing warnings_test properly. ........ r55167 | neal.norwitz | 2007-05-07 01:03:22 -0700 (Mon, 07 May 2007) | 8 lines So long xrange. range() now supports values that are outside -sys.maxint to sys.maxint. floats raise a TypeError. This has been sitting for a long time. It probably has some problems and needs cleanup. Objects/rangeobject.c now uses 4-space indents since it is almost completely new. ........ r55171 | guido.van.rossum | 2007-05-07 10:21:26 -0700 (Mon, 07 May 2007) | 4 lines Fix two tests that were previously depending on significant spaces at the end of a line (and before that on Python 2.x print behavior that has no exact equivalent in 3.0). ........
2007-04-17Remove functions in string module that are also string methods. Also remove:Neal Norwitz-322/+2
* all calls to functions in the string module (except maketrans) * everything from stropmodule except for maketrans() which is still used