summaryrefslogtreecommitdiffstats
path: root/Modules/_localemodule.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-47000: Add `locale.getencoding()` (GH-32068)Inada Naoki2022-04-091-4/+4
|
* bpo-42519: Replace PyMem_MALLOC() with PyMem_Malloc() (GH-23586)Victor Stinner2020-12-011-2/+2
| | | | | | | | | | | No longer use deprecated aliases to functions: * Replace PyMem_MALLOC() with PyMem_Malloc() * Replace PyMem_REALLOC() with PyMem_Realloc() * Replace PyMem_FREE() with PyMem_Free() * Replace PyMem_Del() with PyMem_Free() * Replace PyMem_DEL() with PyMem_Free() Modify also the PyMem_DEL() macro to use directly PyMem_Free().
* bpo-42087: Remove support for AIX 5.3 and below (GH-22830)Kevin Adler2020-11-161-1/+0
| | | | | | As AIX 5.3 and below do not support thread_cputime, it was decided in https://bugs.python.org/issue40680 to require AIX 6.1 and above. This commit removes workarounds for — and references to — older, unsupported AIX versions.
* bpo-42236: Enhance _locale._get_locale_encoding() (GH-23083)Victor Stinner2020-11-011-1/+1
| | | | | | | | | * Rename _Py_GetLocaleEncoding() to _Py_GetLocaleEncodingObject() * Add _Py_GetLocaleEncoding() which returns a wchar_t* string to share code between _Py_GetLocaleEncodingObject() and config_get_locale_encoding(). * _Py_GetLocaleEncodingObject() now decodes nl_langinfo(CODESET) from the current locale encoding with surrogateescape, rather than using UTF-8.
* bpo-42208: Add _locale._get_locale_encoding() (GH-23052)Victor Stinner2020-10-311-2/+18
| | | | | | * Add a new _locale._get_locale_encoding() function to get the current locale encoding. * Modify locale.getpreferredencoding() to use it. * Remove the _bootlocale module.
* bpo-38324: Fix test__locale.py Windows failures (GH-20529)TIGirardi2020-10-201-3/+22
| | | | Use wide-char _W_* fields of lconv structure on Windows Remove "ps_AF" from test__locale.known_numerics on Windows
* bpo-20183: Convert _locale to the Argument Clinic (GH-14201)Zackery Spytz2020-07-151-117/+173
|
* bpo-39943: Add the const qualifier to pointers on non-mutable PyBytes data. ↵Serhiy Storchaka2020-04-121-1/+1
| | | | (GH-19472)
* bpo-1635741: Fix refleak in _locale init error handling (GH-19307)Hai Shi2020-04-021-15/+26
|
* bpo-39824: Convert PyModule_GetState() to get_module_state() (GH-19076)Hai Shi2020-03-191-6/+6
| | | Automerge-Triggered-By: @vstinner
* bpo-39824: module_traverse() don't call m_traverse if md_state=NULL (GH-18738)Victor Stinner2020-03-171-6/+2
| | | | | | | | | | | | | Extension modules: m_traverse, m_clear and m_free functions of PyModuleDef are no longer called if the module state was requested but is not allocated yet. This is the case immediately after the module is created and before the module is executed (Py_mod_exec function). More precisely, these functions are not called if m_size is greater than 0 and the module state (as returned by PyModule_GetState()) is NULL. Extension modules without module state (m_size <= 0) are not affected. Co-Authored-By: Petr Viktorin <encukou@gmail.com>
* bpo-1635741: Port _locale extension module to multiphase initialization (PEP ↵Hai Shi2020-03-111-34/+83
| | | | | 489) (GH-18358) Co-authored-by: Petr Viktorin <pviktori@redhat.com>
* bpo-36254: Fix invalid uses of %d in format strings in C. (GH-12264)Serhiy Storchaka2019-03-131-1/+1
|
* bpo-35441: Remove dead and buggy code related to PyList_SetItem(). (GH-11033)Zackery Spytz2018-12-081-11/+4
| | | | | | | | | | In _localemodule.c and selectmodule.c, remove dead code that would cause double decrefs if run. In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases where a new list is populated and there is no possibility of an error. In addition, check if the list changed size in the loop in array_array_fromlist().
* bpo-28604: Fix localeconv() for different LC_MONETARY (GH-10606)Victor Stinner2018-11-201-16/+93
| | | | | | | | | | | | | | | | | | | | | 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.
* bpo-34485: Enhance init_sys_streams() (GH-8978)Victor Stinner2018-08-281-1/+1
| | | | | | | | | | | | | | | Python now gets the locale encoding with C code to initialize the encoding of standard streams like sys.stdout. Moreover, the encoding is now initialized to the Python codec name to get a normalized encoding name and to ensure that the codec is loaded. The change avoids importing _bootlocale and _locale modules at startup by default. When the PYTHONIOENCODING environment variable only contains an encoding, the error handler is now is now set explicitly to "strict". Rename also get_default_standard_stream_error_handler() to get_stdio_errors(). Reduce the buffer to format the "cpXXX" string (Windows locale encoding).
* bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. ↵Siddhesh Poyarekar2018-04-291-5/+4
| | | | | | | | | (GH-6030) METH_NOARGS functions need only a single argument but they are cast into a PyCFunction, which takes two arguments. This triggers an invalid function cast warning in gcc8 due to the argument mismatch. Fix this by adding a dummy unused argument.
* bpo-31900: Fix localeconv() encoding for LC_NUMERIC (#4174)Victor Stinner2018-01-151-8/+29
| | | | | | | | * 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-29240: Fix locale encodings in UTF-8 Mode (#5170)Victor Stinner2018-01-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Modify locale.localeconv(), time.tzname, os.strerror() and other functions to ignore the UTF-8 Mode: always use the current locale encoding. Changes: * Add _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx(). On decoding or encoding error, they return the position of the error and an error message which are used to raise Unicode errors in PyUnicode_DecodeLocale() and PyUnicode_EncodeLocale(). * Replace _Py_DecodeCurrentLocale() with _Py_DecodeLocaleEx(). * PyUnicode_DecodeLocale() now uses _Py_DecodeLocaleEx() for all cases, especially for the strict error handler. * Add _Py_DecodeUTF8Ex(): return more information on decoding error and supports the strict error handler. * Rename _Py_EncodeUTF8_surrogateescape() to _Py_EncodeUTF8Ex(). * Replace _Py_EncodeCurrentLocale() with _Py_EncodeLocaleEx(). * Ignore the UTF-8 mode to encode/decode localeconv(), strerror() and time zone name. * Remove PyUnicode_DecodeLocale(), PyUnicode_DecodeLocaleAndSize() and PyUnicode_EncodeLocale() now ignore the UTF-8 mode: always use the "current" locale. * Remove _PyUnicode_DecodeCurrentLocale(), _PyUnicode_DecodeCurrentLocaleAndSize() and _PyUnicode_EncodeCurrentLocale().
* [security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302)Serhiy Storchaka2017-06-281-0/+5
| | | | | | | Based on patch by Victor Stinner. Add private C API function _PyUnicode_AsUnicode() which is similar to PyUnicode_AsUnicode(), but checks for null characters.
* allow the first call to wcsxfrm to return ERANGE (#536)Benjamin Peterson2017-03-081-1/+1
| | | If the output buffer provided to wcsxfrm is too small, errno is set to ERANGE. We should not error out in that case.
* bpo-15954: Check return code of wcsxfrm(). (#508)Serhiy Storchaka2017-03-061-4/+12
|
* Issue #28139: Merge indentation fixes from 3.5 into 3.6Martin Panter2016-09-171-1/+2
|\
| * Issue #28139: Fix messed up indentationMartin Panter2016-09-171-1/+2
| | | | | | | | | | Also update the classmethod and staticmethod doc strings and comments to match the RST documentation.
* | Add NULL checks to the initializer of the locale moduleChristian Heimes2016-09-081-34/+20
| | | | | | | | | | | | | | | | The _locale module was using old-style APIs to set numeric module constants from macros. The new way requires less code and properly checks for NULL. CID 1295027
* | Issue #25923: Added more const qualifiers to signatures of static and ↵Serhiy Storchaka2015-12-251-1/+1
|/ | | | private functions.
* Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integerSerhiy Storchaka2015-02-161-1/+1
| | | | overflows. Added few missed PyErr_NoMemory().
* Cleanup locale.localeconv(): move Py_DECREF() closer to the errorVictor Stinner2013-10-291-2/+3
|
* Issue #18408: Fix locale.localeconv(), handle PyDict_SetItemString() failureVictor Stinner2013-07-161-16/+20
|
* Issue #14909: A number of places were using PyMem_Realloc() apis andKristjan Valur Jonsson2012-05-311-2/+3
| | | | | PyObject_GC_Resize() with incorrect error handling. In case of errors, the original object would be leaked. This checkin fixes those cases.
* PyUnicode_DecodeLocale() second argument is now a char*, no more an intVictor Stinner2012-02-141-10/+10
|
* Add PyUnicode_DecodeLocaleAndSize() and PyUnicode_DecodeLocale()Victor Stinner2011-12-161-47/+10
| | | | | | | | | | | * PyUnicode_DecodeLocaleAndSize() and PyUnicode_DecodeLocale() decode a string from the current locale encoding * _Py_char2wchar() writes an "error code" in the size argument to indicate if the function failed because of memory allocation failure or because of a decoding error. The function doesn't write the error message directly to stderr. * Fix time.strftime() (if wcsftime() is missing): decode strftime() result from the current locale encoding, not from the filesystem encoding.
* Remove temporary hacks for the issue #13441Victor Stinner2011-11-211-46/+0
|
* Another temporary hack to debug the issue #13441Victor Stinner2011-11-211-0/+20
| | | | Dump the wchar_t that we are going to decode and dump the locale
* Issue #13441: _PyUnicode_CheckConsistency() dumps the string if the maximumVictor Stinner2011-11-211-0/+26
| | | | | | | character is bigger than U+10FFFF and locale.localeconv() dumps the string before decoding it. Temporary hack to debug the issue #13441.
* Fix a compiler warning in _localeVictor Stinner2011-10-111-1/+1
|
* PyLocale_strxfrm() uses the new Unicode APIVictor Stinner2011-09-291-24/+15
|
* PyUnicode_AsWideCharString() takes a PyObject*, not a PyUnicodeObject*Victor Stinner2010-10-071-2/+2
| | | | | All unicode functions uses PyObject* except PyUnicode_AsWideChar(). Fix the prototype for the new function PyUnicode_AsWideCharString().
* Issue #9979: Use PyUnicode_AsWideCharString() for _locale.strcoll()Victor Stinner2010-09-291-17/+4
| | | | It simplifies the code and prepare the surrogates support.
* Issue 8781: On systems a signed 4-byte wchar_t and a 4-byte Py_UNICODE, use ↵Daniel Stutzbach2010-08-241-4/+4
| | | | memcpy to convert between the two (as already done when wchar_t is unsigned)
* locale.bindtextdomain(): use PyUnicode_FSConverter() to parse the filenameVictor Stinner2010-06-111-5/+17
|
* Recorded merge of revisions 81029 via svnmerge fromAntoine Pitrou2010-05-091-66/+66
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
* Merged revisions 76625 via svnmerge fromAmaury Forgeot d'Arc2009-12-011-0/+8
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r76625 | amaury.forgeotdarc | 2009-12-01 22:51:04 +0100 (mar., 01 déc. 2009) | 3 lines #7419: Fix a crash on Windows in locale.setlocale() when the category is outside the allowed range. ........
* Only declare variable when it's used.Georg Brandl2009-10-271-0/+2
|
* Issue #7080: locale.strxfrm() raises a MemoryError on 64-bit non-WindowsAntoine Pitrou2009-10-191-1/+2
| | | | platforms, and assorted locale fixes by Derk Drukker.
* Merged revisions 74843 via svnmerge fromMark Dickinson2009-09-161-4/+0
| | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r74843 | mark.dickinson | 2009-09-16 21:26:31 +0100 (Wed, 16 Sep 2009) | 4 lines Remove outdated include; this include was breaking OS X builds using non-Apple gcc4.3 and gcc4.4 (because CoreFoundation/CoreFoundation.h won't compile under non-Apple gcc). ........
* Fix for issue 6202Ronald Oussoren2009-06-071-33/+1
|
* Issue #6093: Fix off-by-one error in locale.strxfrm.Martin v. Löwis2009-05-231-1/+1
|
* Issue #1717, stage 2: remove uses of tp_compare in Modules and mostMark Dickinson2009-02-011-1/+3
| | | | Objects.
* Issue #3696: Error parsing arguments on OpenBSD <= 4.4 and Cygwin.Antoine Pitrou2008-09-031-0/+8
| | | | Patch by Amaury Forgeot d'Arc, reviewed by me.