summaryrefslogtreecommitdiffstats
path: root/Python/formatter_unicode.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-35134: Add Include/cpython/longobject.h (GH-29044)Victor Stinner2021-10-191-1/+2
| | | | | | | | | | Move Include/longobject.h non-limited API to a new Include/cpython/longobject.h header file. Move the following definitions to the internal C API: * _PyLong_DigitValue * _PyLong_FormatAdvancedWriter() * _PyLong_FormatWriter()
* bpo-20524: adds better error message for `.format()` (GH-28310)Nikita Sobolev2021-09-241-7/+19
| | | It now lists the bad format_spec and the type of the object.
* bpo-28146: Fix a confusing error message in str.format() (GH-24213)Irit Katriel2021-05-131-2/+8
| | | Automerge-Triggered-By: GH:pitrou
* bpo-27772: Make preceding width with 0 valid in string format. (GH-11270)Serhiy Storchaka2021-01-251-1/+1
| | | | Previously it was an error with confusing error message.
* bpo-41681: Fix for `f-string/str.format` error description when using 2 `,` ↵han-solo2020-09-011-2/+4
| | | | | | | in format specifier (GH-22036) * Fixed `f-string/str.format` error description when using two `,` in format specifier. Co-authored-by: millefalcon <hanish0019@hmail.com>
* bpo-39943: Add the const qualifier to pointers on non-mutable PyUnicode ↵Serhiy Storchaka2020-04-111-3/+3
| | | | data. (GH-19345)
* bpo-38249: Expand Py_UNREACHABLE() to __builtin_unreachable() in the release ↵Serhiy Storchaka2020-03-091-1/+1
| | | | | mode. (GH-16329) Co-authored-by: Victor Stinner <vstinner@python.org>
* closes bpo-39878: Remove unused arguments from static functions. (GH-18822)Andy Lester2020-03-071-10/+10
| | | | | calc_number_widths -> PyObject *number fill_number -> Py_ssize_t d_end
* closes bpo-39803: Remove unused str from _PyLong_FormatAdvancedWriter. ↵Andy Lester2020-03-011-2/+1
| | | | (GH-18709)
* bpo-39573: Use Py_TYPE() macro in Python and Include directories (GH-18391)Victor Stinner2020-02-071-4/+4
| | | Replace direct access to PyObject.ob_type with Py_TYPE().
* Fix typo in formatter_unicode (GH-16831)Hansraj Das2019-10-251-1/+1
| | | numbers's -> number's
* bpo-33954: Fix _PyUnicode_InsertThousandsGrouping() (GH-10623)Victor Stinner2018-11-261-18/+22
| | | | | | | | | | | | Fix str.format(), float.__format__() and complex.__format__() methods for non-ASCII decimal point when using the "n" formatter. Changes: * Rewrite _PyUnicode_InsertThousandsGrouping(): it now requires a _PyUnicodeWriter object for the buffer and a Python str object for digits. * Rename FILL() macro to unicode_fill(), convert it to static inline function, add "assert(0 <= start);" and rework its code.
* bpo-28604: Fix localeconv() for different LC_MONETARY (GH-10606)Victor Stinner2018-11-201-7/+21
| | | | | | | | | | | | | | | | | | | | | locale.localeconv() now sets temporarily the LC_CTYPE locale to the LC_MONETARY locale if the two locales are different and monetary strings are non-ASCII. This temporary change affects other threads. Changes: * locale.localeconv() can now set LC_CTYPE to LC_MONETARY to decode monetary fields. * Add LocaleInfo.grouping_buffer: copy localeconv() grouping string since it can be replaced anytime if a different thread calls localeconv(). * _Py_GetLocaleconvNumeric() now requires a "struct lconv *" structure, so locale.localeconv() now longer calls localeconv() twice. Moreover, the function now requires all arguments to be non-NULL. * Rename STATIC_LOCALE_INFO_INIT to LocaleInfo_STATIC_INIT. * Move _Py_GetLocaleconvNumeric() definition from fileutils.h to pycore_fileutils.h. pycore_fileutils.h now includes locale.h. * The _locale module is now built with Py_BUILD_CORE defined.
* closes bpo-34868: Improve error message with '_' is combined with an invalid ↵Benjamin Peterson2018-10-021-8/+9
| | | | type specifier. (GH-9666)
* bpo-31900: Fix localeconv() encoding for LC_NUMERIC (#4174)Victor Stinner2018-01-151-11/+4
| | | | | | | | * Add _Py_GetLocaleconvNumeric() function: decode decimal_point and thousands_sep fields of localeconv() from the LC_NUMERIC encoding, rather than decoding from the LC_CTYPE encoding. * Modify locale.localeconv() and "n" formatter of str.format() (for int, float and complex to use _Py_GetLocaleconvNumeric() internally.
* bpo-31780: Fix incorrect error message for ',x', ',b', ',o' specs (#4002)Dargor2017-10-151-2/+2
| | | Patch by Pablo.
* bpo-31338 (#3374)Barry Warsaw2017-09-151-5/+2
| | | | | | | * Add Py_UNREACHABLE() as an alias to abort(). * Use Py_UNREACHABLE() instead of assert(0) * Convert more unreachable code to use Py_UNREACHABLE() * Document Py_UNREACHABLE() and a few other macros.
* bpo-30923: Silence fall-through warnings included in -Wextra since gcc-7.0. ↵Stefan Krah2017-08-211-0/+1
| | | | (#3157)
* merge 3.5 (#28119)Benjamin Peterson2016-09-141-22/+14
|\
| * improve type-safe of and prevent double-frees in get_locale_info (#28119)Benjamin Peterson2016-09-141-17/+9
| |
| * Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Martin Panter2016-09-071-1/+1
| |
* | make invalid_comma_and_underscore a real prototypeBenjamin Peterson2016-09-101-1/+1
| |
* | Issue 27080: PEP 515: add '_' formatting option.Eric V. Smith2016-09-101-21/+51
| |
* | Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Raymond Hettinger2016-08-301-1/+1
| |
* | Issue #27818: Speed up parsing width and precision in format() strings forSerhiy Storchaka2016-08-291-9/+16
| | | | | | | | numbers. Patch by Stefan Behnel.
* | Merge typo fixes from 3.5Martin Panter2016-05-081-2/+2
|\ \ | |/
| * Corrections for a/an in code comments and documentationMartin Panter2016-05-081-2/+2
| |
* | Issue #25923: Added the const qualifier to static constant arrays.Serhiy Storchaka2015-12-251-1/+1
|/
* Close issue #8931: Make alternate formatting for 'c' raise an exception. ↵Eric V. Smith2014-04-161-0/+7
| | | | Patch by Torsten Landschoff.
* Issue #12546: Allow \x00 as a fill character for builtin type __format__ ↵Eric V. Smith2014-04-141-11/+8
| | | | methods.
* Add _PyUnicodeWriter_WriteASCIIString() functionVictor Stinner2013-11-191-9/+9
|
* Issue #18783: Removed existing mentions of Python long type in docstrings,Serhiy Storchaka2013-08-271-2/+1
|\ | | | | | | error messages and comments.
| * Issue #18783: Removed existing mentions of Python long type in docstrings,Serhiy Storchaka2013-08-271-2/+1
| | | | | | | | error messages and comments.
* | Issue #9566: Fix a compiler warning on Windows x64Victor Stinner2013-06-241-4/+2
| |
* | (Merge 3.3) Issue #18137: Detect integer overflow on precision inVictor Stinner2013-06-231-2/+14
|\ \ | |/ | | | | float.__format__() and complex.__format__().
| * Issue #18137: Detect integer overflow on precision in float.__format__() andVictor Stinner2013-06-231-2/+14
| | | | | | | | complex.__format__().
* | Fix a compilater warning on Windows 64-bitVictor Stinner2013-05-161-1/+1
| |
* | Fix a compiler warning: use unsigned int type instead of enum PyUnicode_Kind toVictor Stinner2013-05-071-1/+1
| | | | | | | | compare two Unicode kinds
* | Close #16757: Avoid calling the expensive _PyUnicode_FindMaxChar() functionVictor Stinner2013-04-031-1/+5
| | | | | | | | when possible
* | Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) ↵Antoine Pitrou2013-02-091-1/+1
|\ \ | |/ | | | | | | | | | | | | 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).
| * Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) ↵Antoine Pitrou2013-02-091-1/+1
| |\ | | | | | | | | | | | | | | | | | | | | | 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).
* | | Issue #15609: Optimize str%args for integer argumentVictor Stinner2012-10-011-1/+2
|/ / | | | | | | | | | | | | | | | | | | - 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
* | After the jump in line 1051 unicode_tmp is NULL. Found by Coverity.Stefan Krah2012-09-061-1/+1
| |
* | Remove now unused IntOrLongToString typeVictor Stinner2012-08-091-3/+0
| |
* | Comment out a dead increment.Brett Cannon2012-06-251-1/+1
| | | | | | | | Found by Clang's static analyzer.
* | format_obj: make it staticdoko@ubuntu.com2012-06-211-1/+1
| |
* | Optimize _PyUnicode_FastCopyCharacters() when maxchar(from) > maxchar(to)Victor Stinner2012-06-161-2/+4
| |
* | Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args ↵Victor Stinner2012-05-291-194/+218
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Close #14648: Compute correctly maxchar in str.format() for substrinVictor Stinner2012-04-231-4/+2
| |
* | inherit maxchar of field value where needed (closes #14648)Benjamin Peterson2012-04-231-0/+3
| |