Commit Graph

48 Commits

Author SHA1 Message Date
Martin Panter 1ce738e08f Merge typo fixes from 3.5 2016-05-08 14:02:35 +00:00
Martin Panter 4c35964b76 Corrections for a/an in code comments and documentation 2016-05-08 13:53:41 +00:00
Serhiy Storchaka 2d06e84455 Issue #25923: Added the const qualifier to static constant arrays. 2015-12-25 19:53:18 +02:00
Eric V. Smith a12572ff3a Close issue #8931: Make alternate formatting for 'c' raise an exception. Patch by Torsten Landschoff. 2014-04-15 22:37:55 -04:00
Eric V. Smith 2ea9712ee9 Issue #12546: Allow \x00 as a fill character for builtin type __format__ methods. 2014-04-14 11:55:10 -04:00
Victor Stinner 4a58707a34 Add _PyUnicodeWriter_WriteASCIIString() function 2013-11-19 12:54:53 +01:00
Serhiy Storchaka 46e1ce214b Issue #18783: Removed existing mentions of Python long type in docstrings,
error messages and comments.
2013-08-27 20:17:03 +03:00
Serhiy Storchaka 9594942716 Issue #18783: Removed existing mentions of Python long type in docstrings,
error messages and comments.
2013-08-27 19:40:23 +03:00
Victor Stinner 76d38502e4 Issue #9566: Fix a compiler warning on Windows x64 2013-06-24 23:34:15 +02:00
Victor Stinner 2ab07f01a4 (Merge 3.3) Issue #18137: Detect integer overflow on precision in
float.__format__() and complex.__format__().
2013-06-23 14:55:43 +02:00
Victor Stinner 2f084ecfe7 Issue #18137: Detect integer overflow on precision in float.__format__() and
complex.__format__().
2013-06-23 14:54:30 +02:00
Victor Stinner 9ce59bbe43 Fix a compilater warning on Windows 64-bit 2013-05-17 00:04:56 +02:00
Victor Stinner 22c103b3cc Fix a compiler warning: use unsigned int type instead of enum PyUnicode_Kind to
compare two Unicode kinds
2013-05-07 23:50:03 +02:00
Victor Stinner eb4b5ac8af Close #16757: Avoid calling the expensive _PyUnicode_FindMaxChar() function
when possible
2013-04-03 02:02:33 +02:00
Antoine Pitrou 8ad5b07ccb Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) in the interpreter.
I've left a couple of them in: zlib (third-party lib), getaddrinfo.c
(doesn't include Python.h, and probably obsolete), _sre.c (legitimate
use for the re.LOCALE flag), mpdecimal (needs to build without Python.h).
2013-02-09 23:16:51 +01:00
Antoine Pitrou c73c561181 Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) in the interpreter.
I've left a couple of them in: zlib (third-party lib), getaddrinfo.c
(doesn't include Python.h, and probably obsolete), _sre.c (legitimate
use for the re.LOCALE flag), mpdecimal (needs to build without Python.h).
2013-02-09 23:14:42 +01:00
Victor Stinner 621ef3d84f Issue #15609: Optimize str%args for integer argument
- Use _PyLong_FormatWriter() instead of formatlong() when possible, to avoid
   a temporary buffer
 - Enable the fast path when width is smaller or equals to the length,
   and when the precision is bigger or equals to the length
 - Add unit tests!
 - formatlong() uses PyUnicode_Resize() instead of _PyUnicode_FromASCII()
   to resize the output string
2012-10-02 00:33:47 +02:00
Stefan Krah d9c1bf7f1f After the jump in line 1051 unicode_tmp is NULL. Found by Coverity. 2012-09-06 13:02:46 +02:00
Victor Stinner 2d6266d5f1 Remove now unused IntOrLongToString type 2012-08-09 21:38:23 +02:00
Brett Cannon 8a250fac15 Comment out a dead increment.
Found by Clang's static analyzer.
2012-06-25 16:13:44 -04:00
doko@ubuntu.com 39378f7f4f format_obj: make it static 2012-06-21 12:12:20 +02:00
Victor Stinner c9d369f1bf Optimize _PyUnicode_FastCopyCharacters() when maxchar(from) > maxchar(to) 2012-06-16 02:22:37 +02:00
Victor Stinner d3f0882dfb Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
* Formatting string, int, float and complex use the _PyUnicodeWriter API. It
   avoids a temporary buffer in most cases.
 * Add _PyUnicodeWriter_WriteStr() to restore the PyAccu optimization: just
   keep a reference to the string if the output is only composed of one string
 * Disable overallocation when formatting the last argument of str%args and
   str.format(args)
 * Overallocation allocates at least 100 characters: add min_length attribute
   to the _PyUnicodeWriter structure
 * Add new private functions: _PyUnicode_FastCopyCharacters(),
   _PyUnicode_FastFill() and _PyUnicode_FromASCII()

The speed up is around 20% in average.
2012-05-29 12:57:52 +02:00
Victor Stinner ece58deb9f Close #14648: Compute correctly maxchar in str.format() for substrin 2012-04-23 23:36:38 +02:00
Benjamin Peterson 80d07f8251 inherit maxchar of field value where needed (closes #14648) 2012-04-23 10:55:29 -04:00
Victor Stinner 90f50d4df9 Issue #13706: Fix format(float, "n") for locale with non-ASCII decimal point (e.g. ps_aF) 2012-02-24 01:44:47 +01:00
Victor Stinner 41a863cb81 Issue #13706: Fix format(int, "n") for locale with non-ASCII thousands separator
* Decode thousands separator and decimal point using PyUnicode_DecodeLocale()
   (from the locale encoding), instead of decoding them implicitly from latin1
 * Remove _PyUnicode_InsertThousandsGroupingLocale(), it was not used
 * Change _PyUnicode_InsertThousandsGrouping() API to return the maximum
   character if unicode is NULL
 * Replace MIN/MAX macros by Py_MIN/Py_MAX
 * stringlib/undef.h undefines STRINGLIB_IS_UNICODE
 * stringlib/localeutil.h only supports Unicode
2012-02-24 00:37:51 +01:00
Victor Stinner ed27785b32 Issue #13706: Add assertions to detect bugs earlier 2012-02-01 00:22:23 +01:00
Amaury Forgeot d'Arc 6d766fc3fa Silence last compilation warning. 2012-01-23 23:20:43 +01:00
Amaury Forgeot d'Arc cd27df3a99 Fix compilation warnings (seen on win32 buildbot) 2012-01-23 22:42:19 +01:00
Victor Stinner a4ac600d6f Issue #13706: Support non-ASCII fill characters 2012-01-21 15:50:49 +01:00
Eric V. Smith d25cfe66f5 Improve exception text. Closes issue 13811. 2012-01-19 20:04:28 -05:00
Benjamin Peterson 21e0da228d remove some usage of Py_UNICODE_TOUPPER/LOWER 2012-01-11 21:00:42 -05:00
Victor Stinner 3fe553160c Add a new PyUnicode_Fill() function
It is faster than the unicode_fill() function which was implemented in
formatter_unicode.c.
2012-01-04 00:33:50 +01:00
Mark Dickinson 47862d4c0e Issue #9530: Fix undefined behaviour due to signed overflow in Python/formatter_unicode.c. 2011-12-01 15:27:04 +00:00
Victor Stinner c4f281eba3 Fix misuse of PyUnicode_GET_SIZE, use PyUnicode_GET_LENGTH instead 2011-10-11 22:11:42 +02:00
Martin v. Löwis c47adb04b3 Change PyUnicode_KIND to 1,2,4. Drop _KIND_SIZE and _CHARACTER_SIZE. 2011-10-07 20:55:35 +02:00
Victor Stinner fb9ea8c57e Don't check for the maximum character when copying from unicodeobject.c
* Create copy_characters() function which doesn't check for the maximum
   character in release mode
 * _PyUnicode_CheckConsistency() is no more static to be able to use it
   in _PyUnicode_FormatAdvanced() (in formatter_unicode.c)
 * _PyUnicode_CheckConsistency() checks the string hash
2011-10-06 01:45:57 +02:00
Victor Stinner c3cec7868b Add asciilib: similar to ucs1, ucs2 and ucs4 library, but specialized to ASCII
ucs1, ucs2 and ucs4 libraries have to scan created substring to find the
maximum character, whereas it is not need to ASCII strings. Because ASCII
strings are common, it is useful to optimize ASCII.
2011-10-05 21:24:08 +02:00
Victor Stinner fd85c3aa8d fill_number() and format_string_internal() check for PyUnicode_CopyCharacters() failure 2011-09-28 21:53:49 +02:00
Victor Stinner dba2deeca2 fill_number() ensures that the 'digits' string is ready 2011-09-28 21:50:42 +02:00
Victor Stinner afbaa20fb9 fill_char() can now propagate an error 2011-09-28 21:50:16 +02:00
Martin v. Löwis d63a3b8beb Implement PEP 393. 2011-09-28 07:41:54 +02:00
Mark Dickinson 01458c7a62 Remove the uses of WITHOUT_COMPLEX introduced in r75471 2009-10-18 16:41:32 +00:00
Mark Dickinson 42e30556e5 Merged revisions 75440 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r75440 | mark.dickinson | 2009-10-15 18:45:39 +0100 (Thu, 15 Oct 2009) | 1 line

  Allow core Python build to succeed under WITHOUT_COMPLEX.  The module build stage still fails.
........
2009-10-15 19:55:18 +00:00
Eric Smith 58a42244cf Issue #1588: Add complex.__format__. 2009-04-30 01:00:33 +00:00
Eric Smith 4a7d76ddb5 Refactor and clean up str.format() code (and helpers) in advance of optimizations. 2008-05-30 18:10:19 +00:00
Eric Smith 8c66326368 Implementation of PEP 3101, Advanced String Formatting.
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-25 02:26:07 +00:00