
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2018-06-25 08:23 byvstinner, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 10623 | merged | vstinner,2018-11-20 21:35 | |
| PR 10717 | closed | miss-islington,2018-11-26 12:40 | |
| PR 10718 | merged | vstinner,2018-11-26 12:45 | |
| PR 10720 | merged | vstinner,2018-11-26 14:16 | |
| PR 10737 | merged | vstinner,2018-11-27 11:12 | |
| PR 10738 | merged | vstinner,2018-11-27 11:20 | |
| PR 10740 | merged | vstinner,2018-11-27 11:23 | |
| Messages (14) | |||
|---|---|---|---|
| msg320403 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2018-06-25 08:23 | |
Example:vstinner@apu$ ./pythonPython 3.8.0a0 (heads/master-dirty:bcd3a1a18d, Jun 23 2018, 10:31:03) [GCC 8.1.1 20180502 (Red Hat 8.1.1-1)] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import locale>>> locale.str(2.5)'2.5'>>> '{:n}'.format(2.5)'2.5'>>> locale.setlocale(locale.LC_ALL, '')'fr_FR.UTF-8'>>> locale.str(2.5)'2,5'>>> '{:n}'.format(2.5)python:Objects/unicodeobject.c:474: _PyUnicode_CheckConsistency: Assertion `maxchar < 128' failed.Aborted (core dumped)Another example:vstinner@apu$ ./pythonPython 3.8.0a0 (heads/master-dirty:bcd3a1a18d, Jun 23 2018, 10:31:03) >>> import locale; locale.setlocale(locale.LC_ALL, '')'fr_FR.UTF-8'>>> (2.5).__format__('n')python:Objects/unicodeobject.c:474: _PyUnicode_CheckConsistency: Assertion `maxchar < 128' failed.Aborted (core dumped)Result of my system Python 3.6 of Fedora 28:vstinner@apu$ python3Python 3.6.5 (default, Mar 29 2018, 18:20:46) [GCC 8.0.1 20180317 (Red Hat 8.0.1-0.19)] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import locale>>> locale.str(2.5)'2.5'>>> '{:n}'.format(2.5)'2.5'>>> locale.setlocale(locale.LC_ALL, '')'fr_FR.UTF-8'>>> locale.str(2.5)'2,5'>>> '{:n}'.format(2.5)'°,5'>>> '{:n}'.format(3.5)'°,5'>>> '{:n}'.format(33.5)'°\x18,5'>>> '{:n}'.format(333.5)'°\x186,5' | |||
| msg320635 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2018-06-27 22:35 | |
Aha, the problem occurs when the thousands separator code point is greater than 255.On my Fedora 28 (glibc 2.27), it's U+202f:vstinner@apu$ ./pythonPython 3.8.0a0 (heads/master-dirty:492572715a, Jun 28 2018, 00:18:54) >>> import locale>>> locale.setlocale(locale.LC_ALL, '')'fr_FR.UTF-8'>>> locale.localeconv()['thousands_sep']'\u202f'The bug is in _PyUnicode_InsertThousandsGrouping(): if thousands_sep kind is different than unicode kind, "data = _PyUnicode_AsKind(unicode, thousands_sep_kind);" is used, but later this memory is released. So the function writes into a temporary buffer which is then released. It doesn't work...It seems like I introduced the regression 6 years ago inbpo-13706:commit90f50d4df9e21093f006427fd7ed11a0d704f792Author: Victor Stinner <victor.stinner@haypocalc.com>Date: Fri Feb 24 01:44:47 2012 +0100 Issue#13706: Fix format(float, "n") for locale with non-ASCII decimal point (e.g. ps_aF) | |||
| msg320669 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2018-06-28 14:45 | |
> The bug is in _PyUnicode_InsertThousandsGrouping()This function should take a _PyUnicodeWriter as input, not a PyUnicodeObject. | |||
| msg330157 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2018-11-20 22:00 | |
Minimum reproducer, on Fedora 29:import localelocale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')print(ascii('{:n}'.format(1.5)))Current result:'H,5'Output withPR 10623:'1,5' | |||
| msg330211 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2018-11-21 17:19 | |
My private test suite for locales:https://github.com/vstinner/misc/blob/master/python/test_all_locales.pySince each platform uses a different locale database, it's hard to write reliable portable and future-proof tests :-(My tests only work on specific Windows, macOS, FreeBSD and Linux versions. | |||
| msg330429 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2018-11-26 12:40 | |
New changeset59423e3ddd736387cef8f7632c71954c1859bed0 by Victor Stinner in branch 'master':bpo-33954: Fix _PyUnicode_InsertThousandsGrouping() (GH-10623)https://github.com/python/cpython/commit/59423e3ddd736387cef8f7632c71954c1859bed0 | |||
| msg330431 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2018-11-26 13:17 | |
New changeset6f5fa1b4be735159e964906ab608dc467476e47c by Victor Stinner in branch '3.7':bpo-33954: Fix _PyUnicode_InsertThousandsGrouping() (GH-10623) (GH-10718)https://github.com/python/cpython/commit/6f5fa1b4be735159e964906ab608dc467476e47c | |||
| msg330444 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2018-11-26 16:03 | |
New changesetfc4a44b0c3a69390eca4680d89c2ae5fe967f882 by Victor Stinner in branch '3.6':bpo-33954: Fix _PyUnicode_InsertThousandsGrouping() (GH-10623) (GH-10718) (GH-10720)https://github.com/python/cpython/commit/fc4a44b0c3a69390eca4680d89c2ae5fe967f882 | |||
| msg330445 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2018-11-26 16:06 | |
Python 3.6, 3.7 and master have been fixed. | |||
| msg330494 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2018-11-27 07:10 | |
Objects/unicodeobject.c: In function ‘_PyUnicode_FastFill’:Objects/unicodeobject.c:10126:24: warning: passing argument 2 of ‘unicode_fill’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] unicode_fill(kind, data, fill_char, start, length); ^~~~Objects/unicodeobject.c:224:1: note: expected ‘void *’ but argument is of type ‘const void *’ unicode_fill(enum PyUnicode_Kind kind, void *data, Py_UCS4 value, ^~~~~~~~~~~~In file included from /usr/include/wchar.h:850:0, from ./Include/unicodeobject.h:97, from ./Include/Python.h:87, from ./Modules/getpath.c:3: | |||
| msg330510 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2018-11-27 11:41 | |
New changeset163403a63e9272fcd14707e344122c2e3c5e0244 by Victor Stinner in branch 'master':bpo-33954: Fix compiler warning in _PyUnicode_FastFill() (GH-10737)https://github.com/python/cpython/commit/163403a63e9272fcd14707e344122c2e3c5e0244 | |||
| msg330511 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2018-11-27 11:42 | |
New changeset7f9fb0f34555641722be5468b7fbd53dd3c0f1e2 by Victor Stinner in branch '3.7':bpo-33954: Rewrite FILL() macro of unicodeobject.c (GH-10738)https://github.com/python/cpython/commit/7f9fb0f34555641722be5468b7fbd53dd3c0f1e2 | |||
| msg330517 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2018-11-27 13:31 | |
New changeset54fa83e0a3f3b077763cb50705d7a7dbe4a40a4a by Victor Stinner in branch '3.6':bpo-33954: Rewrite FILL() macro of unicodeobject.c (GH-10740)https://github.com/python/cpython/commit/54fa83e0a3f3b077763cb50705d7a7dbe4a40a4a | |||
| msg330518 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2018-11-27 13:32 | |
Serhiy Storchaka:"""Objects/unicodeobject.c: In function ‘_PyUnicode_FastFill’:Objects/unicodeobject.c:10126:24: warning: passing argument 2 of ‘unicode_fill’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]"""Yeah, I was aware of the warning. I had a local branch but I started to make many unrelated changes and so I lost track of the issue :-)The warning should now be fixed. Thanks for the report.Note: it was a real bug which exists since at least Python 3.6 ;-) | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:02 | admin | set | github: 78135 |
| 2020-01-12 02:29:51 | cheryl.sabella | link | issue33471 superseder |
| 2019-01-04 23:31:03 | vstinner | link | issue35432 superseder |
| 2018-11-27 13:32:20 | vstinner | set | messages: +msg330518 |
| 2018-11-27 13:31:00 | vstinner | set | messages: +msg330517 |
| 2018-11-27 11:42:08 | vstinner | set | messages: +msg330511 |
| 2018-11-27 11:41:20 | vstinner | set | messages: +msg330510 |
| 2018-11-27 11:23:06 | vstinner | set | pull_requests: +pull_request9987 |
| 2018-11-27 11:20:29 | vstinner | set | pull_requests: +pull_request9985 |
| 2018-11-27 11:12:10 | vstinner | set | pull_requests: +pull_request9984 |
| 2018-11-27 07:10:08 | serhiy.storchaka | set | nosy: +serhiy.storchaka messages: +msg330494 |
| 2018-11-26 16:06:00 | vstinner | set | status: open -> closed resolution: fixed messages: +msg330445 stage: patch review -> resolved |
| 2018-11-26 16:03:39 | vstinner | set | messages: +msg330444 |
| 2018-11-26 14:16:34 | vstinner | set | pull_requests: +pull_request9968 |
| 2018-11-26 13:17:06 | vstinner | set | messages: +msg330431 |
| 2018-11-26 12:45:29 | vstinner | set | pull_requests: +pull_request9967 |
| 2018-11-26 12:40:18 | miss-islington | set | pull_requests: +pull_request9966 |
| 2018-11-26 12:40:03 | vstinner | set | messages: +msg330429 |
| 2018-11-21 17:19:07 | vstinner | set | messages: +msg330211 |
| 2018-11-20 22:00:43 | vstinner | set | messages: +msg330157 |
| 2018-11-20 21:35:49 | vstinner | set | keywords: +patch stage: patch review pull_requests: +pull_request9871 |
| 2018-08-05 17:54:55 | ppperry | set | title: float.__format__('n') fails with _PyUnicode_CheckConsistency assertion error -> float.__format__('n') fails with _PyUnicode_CheckConsistency assertion error for locales with non-ascii thousands separator |
| 2018-08-05 12:45:57 | xtreak | set | nosy: +xtreak |
| 2018-06-28 14:45:48 | vstinner | set | messages: +msg320669 |
| 2018-06-28 13:57:20 | mark.dickinson | set | nosy: +mark.dickinson,eric.smith |
| 2018-06-27 22:35:49 | vstinner | set | messages: +msg320635 |
| 2018-06-25 08:32:07 | vstinner | set | versions: + Python 3.6, Python 3.7 |
| 2018-06-25 08:23:46 | vstinner | create | |