Miss Islington (bot) and Jelle Zijlstra
bae32d612d
[3.14] gh-159739: Check character formatting allocation failure (GH-159746) ( #159840 )
...
Propagate the error from PyUnicode_FromOrdinal() before using the
result.
(cherry picked from commit 5b0ab21364 )
Co-authored-by: Jelle Zijlstra <jelle@openai.com >
2026-10-20 08:45:25 -07:00
Mark Shannon
a1aeec61c4
GH-131238: Core header refactor (GH-131250)
...
* Moves most structs in pycore_ header files into pycore_structs.h and pycore_runtime_structs.h
* Removes many cross-header dependencies
2025-03-17 09:19:04 +00:00
Sergey B Kirpichev
2352bd418a
gh-130860: Fix width calculation, when separators in fractional part (GH-130865)
...
This amends f39a07be47
2025-03-06 14:26:29 +02:00
Sergey Miryanov
3a7f17c7e2
gh-130790: Remove references about unicode's readiness from comments ( #130801 )
2025-03-03 19:18:09 +00:00
Sergey B Kirpichev
f39a07be47
gh-87790: support thousands separators for formatting fractional part of floats ( #125304 )
...
```pycon
>>> f"{123_456.123_456:_._f}" # Whole and fractional
'123_456.123_456'
>>> f"{123_456.123_456:_f}" # Integer component only
'123_456.123456'
>>> f"{123_456.123_456:._f}" # Fractional component only
'123456.123_456'
>>> f"{123_456.123_456:.4_f}" # with precision
'123456.1_235'
```
2025-02-25 16:27:07 +01:00
Victor Stinner
b9a8ca0a6a
gh-115754: Use Py_GetConstant(Py_CONSTANT_EMPTY_STR) ( #125194 )
...
Replace PyUnicode_New(0, 0), PyUnicode_FromString("")
and PyUnicode_FromStringAndSize("", 0)
with Py_GetConstant(Py_CONSTANT_EMPTY_STR).
2024-10-09 17:15:23 +02:00
Victor Stinner and Nikita Sobolev
12af8ec864
gh-121040: Use __attribute__((fallthrough)) ( #121044 )
...
Fix warnings when using -Wimplicit-fallthrough compiler flag.
Annotate explicitly "fall through" switch cases with a new
_Py_FALLTHROUGH macro which uses __attribute__((fallthrough)) if
available. Replace "fall through" comments with _Py_FALLTHROUGH.
Add _Py__has_attribute() macro. No longer define __has_attribute()
macro if it's not defined. Move also _Py__has_builtin() at the top
of pyport.h.
Co-Authored-By: Nikita Sobolev <mail@sobolevn.me >
2024-06-27 09:58:44 +00:00
Victor Stinner
ef300937c2
gh-92536: Remove PyUnicode_READY() calls ( #105210 )
...
Since Python 3.12, PyUnicode_READY() does nothing and always
returns 0.
2023-06-02 01:33:17 +02:00
Victor Stinner
f62ad4f2c4
gh-89653: Use int type for Unicode kind ( #92704 )
...
Use the same type that PyUnicode_FromKindAndData() kind parameter
type (public C API): int.
2022-05-13 12:41:05 +02:00
John Belmonte and Mark Dickinson
b0b836b20c
bpo-45995: add "z" format specifer to coerce negative 0 to zero (GH-30049)
...
Add "z" format specifier to coerce negative 0 to zero.
See https://github.com/python/cpython/issues/90153 (originally https://bugs.python.org/issue45995 ) for discussion.
This covers `str.format()` and f-strings. Old-style string interpolation is not supported.
Co-authored-by: Mark Dickinson <dickinsm@gmail.com >
2022-04-11 15:34:18 +01:00
Oleg Iarygin
a52f82baf2
bpo-46920: Remove disabled debug code added decades ago and likely unnecessary (GH-31812)
2022-03-14 17:03:21 +01:00
Victor Stinner
5f09bb021a
bpo-35134: Add Include/cpython/longobject.h (GH-29044)
...
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()
2021-10-19 02:04:52 +02:00
Nikita Sobolev
8d8729146f
bpo-20524: adds better error message for .format() (GH-28310)
...
It now lists the bad format_spec and the type of the object.
2021-09-24 11:18:04 -04:00
Irit Katriel
4aeee0b47b
bpo-28146: Fix a confusing error message in str.format() (GH-24213)
...
Automerge-Triggered-By: GH:pitrou
2021-05-13 13:55:55 -07:00
Serhiy Storchaka
cf19cc3b92
bpo-27772: Make preceding width with 0 valid in string format. (GH-11270)
...
Previously it was an error with confusing error message.
2021-01-25 11:56:33 +02:00
han-solo and millefalcon
0d6aa7f0ee
bpo-41681: Fix for f-string/str.format error description when using 2 , 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 >
2020-09-01 10:34:29 -04:00
Serhiy Storchaka
cd8295ff75
bpo-39943: Add the const qualifier to pointers on non-mutable PyUnicode data. (GH-19345)
2020-04-11 10:48:40 +03:00
Serhiy Storchaka and Victor Stinner
eebaa9bfc5
bpo-38249: Expand Py_UNREACHABLE() to __builtin_unreachable() in the release mode. (GH-16329)
...
Co-authored-by: Victor Stinner <vstinner@python.org >
2020-03-09 20:49:52 +02:00
Andy Lester
ad0c775ea2
closes bpo-39878: Remove unused arguments from static functions. (GH-18822)
...
calc_number_widths -> PyObject *number
fill_number -> Py_ssize_t d_end
2020-03-07 09:29:10 -08:00
Andy Lester
3fe9117779
closes bpo-39803: Remove unused str from _PyLong_FormatAdvancedWriter. (GH-18709)
2020-03-01 13:26:43 -08:00
Victor Stinner
a102ed7d2f
bpo-39573: Use Py_TYPE() macro in Python and Include directories (GH-18391)
...
Replace direct access to PyObject.ob_type with Py_TYPE().
2020-02-07 02:24:48 +01:00
Hansraj Das
7320ec05f7
Fix typo in formatter_unicode (GH-16831)
...
numbers's -> number's
2019-10-25 09:44:02 -07:00
Victor Stinner
59423e3ddd
bpo-33954: Fix _PyUnicode_InsertThousandsGrouping() (GH-10623)
...
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.
2018-11-26 13:40:01 +01:00
Victor Stinner
02e6bf7f20
bpo-28604: Fix localeconv() for different LC_MONETARY (GH-10606)
...
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.
2018-11-20 16:20:16 +01:00
Benjamin Peterson
cbda8fc5d7
closes bpo-34868: Improve error message with '_' is combined with an invalid type specifier. (GH-9666)
2018-10-01 21:54:39 -07:00
Victor Stinner
cb064fc232
bpo-31900: Fix localeconv() encoding for LC_NUMERIC ( #4174 )
...
* 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.
2018-01-15 15:58:02 +01:00
Dargor
28773ca7a7
bpo-31780: Fix incorrect error message for ',x', ',b', ',o' specs ( #4002 )
...
Patch by Pablo.
2017-10-14 23:41:13 -04:00
Barry Warsaw
b2e5794870
bpo-31338 ( #3374 )
...
* 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.
2017-09-14 18:13:16 -07:00
Stefan Krah
f432a3234f
bpo-30923: Silence fall-through warnings included in -Wextra since gcc-7.0. ( #3157 )
2017-08-21 13:09:59 +02:00
Benjamin Peterson
995026a8a9
merge 3.5 ( #28119 )
2016-09-13 22:46:15 -07:00
Benjamin Peterson
59e5e0dca2
improve type-safe of and prevent double-frees in get_locale_info ( #28119 )
2016-09-13 22:43:45 -07:00
Benjamin Peterson
eb0dfa9251
make invalid_comma_and_underscore a real prototype
2016-09-09 20:14:05 -07:00
Eric V. Smith
89e1b1aae0
Issue 27080: PEP 515: add '_' formatting option.
2016-09-09 23:06:47 -04:00
Martin Panter
0be894b2f6
Issue #27895 : Spelling fixes (Contributed by Ville Skyttä).
2016-09-07 12:03:06 +00:00
Raymond Hettinger
15f44ab043
Issue #27895 : Spelling fixes (Contributed by Ville Skyttä).
2016-08-30 10:47:49 -07:00
Serhiy Storchaka
1f9326196e
Issue #27818 : Speed up parsing width and precision in format() strings for
...
numbers. Patch by Stefan Behnel.
2016-08-29 15:57:26 +03:00
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