summaryrefslogtreecommitdiffstats
path: root/Modules/_localemodule.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Merged revisions ↵Georg Brandl2008-07-231-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 65012,65035,65037-65040,65048,65057,65077,65091-65095,65097-65099,65127-65128,65131,65133-65136,65139,65149-65151,65155,65158-65159,65176-65178,65183-65184,65187-65190,65192,65194 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r65012 | jesse.noller | 2008-07-16 15:24:06 +0200 (Wed, 16 Jul 2008) | 2 lines Apply patch for issue 3090: ARCHFLAGS parsing incorrect ........ r65035 | georg.brandl | 2008-07-16 23:19:28 +0200 (Wed, 16 Jul 2008) | 2 lines #3045: fix pydoc behavior for TEMP path with spaces. ........ r65037 | georg.brandl | 2008-07-16 23:31:41 +0200 (Wed, 16 Jul 2008) | 2 lines #1608818: errno can get set by every call to readdir(). ........ r65038 | georg.brandl | 2008-07-17 00:04:20 +0200 (Thu, 17 Jul 2008) | 2 lines #3305: self->stream can be NULL. ........ r65039 | georg.brandl | 2008-07-17 00:09:17 +0200 (Thu, 17 Jul 2008) | 2 lines #3345: fix docstring. ........ r65040 | georg.brandl | 2008-07-17 00:33:18 +0200 (Thu, 17 Jul 2008) | 2 lines #3312: fix two sqlite3 crashes. ........ r65048 | georg.brandl | 2008-07-17 01:35:54 +0200 (Thu, 17 Jul 2008) | 2 lines #3388: add a paragraph about using "with" for file objects. ........ r65057 | gregory.p.smith | 2008-07-17 05:13:05 +0200 (Thu, 17 Jul 2008) | 2 lines news note for r63052 ........ r65077 | jesse.noller | 2008-07-17 23:01:05 +0200 (Thu, 17 Jul 2008) | 3 lines Fix issue 3395, update _debugInfo to be _debug_info ........ r65091 | ronald.oussoren | 2008-07-18 07:48:03 +0200 (Fri, 18 Jul 2008) | 2 lines Last bit of a fix for issue3381 (addon for my patch in r65061) ........ r65092 | vinay.sajip | 2008-07-18 10:59:06 +0200 (Fri, 18 Jul 2008) | 1 line Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch. ........ r65093 | vinay.sajip | 2008-07-18 11:00:00 +0200 (Fri, 18 Jul 2008) | 1 line Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch. ........ r65094 | vinay.sajip | 2008-07-18 11:00:35 +0200 (Fri, 18 Jul 2008) | 1 line Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch. ........ r65095 | vinay.sajip | 2008-07-18 11:01:10 +0200 (Fri, 18 Jul 2008) | 1 line Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch. ........ r65097 | georg.brandl | 2008-07-18 12:20:59 +0200 (Fri, 18 Jul 2008) | 2 lines Remove duplicate entry in __all__. ........ r65098 | georg.brandl | 2008-07-18 12:29:30 +0200 (Fri, 18 Jul 2008) | 2 lines Correct attribute name. ........ r65099 | georg.brandl | 2008-07-18 13:15:06 +0200 (Fri, 18 Jul 2008) | 3 lines Document the different meaning of precision for {:f} and {:g}. Also document how inf and nan are formatted. #3404. ........ r65127 | raymond.hettinger | 2008-07-19 02:42:03 +0200 (Sat, 19 Jul 2008) | 1 line Improve accuracy of gamma test function ........ r65128 | raymond.hettinger | 2008-07-19 02:43:00 +0200 (Sat, 19 Jul 2008) | 1 line Add recipe to the itertools docs. ........ r65131 | georg.brandl | 2008-07-19 12:08:55 +0200 (Sat, 19 Jul 2008) | 2 lines #3378: in case of no memory, don't leak even more memory. :) ........ r65133 | georg.brandl | 2008-07-19 14:39:10 +0200 (Sat, 19 Jul 2008) | 3 lines #3302: fix segfaults when passing None for arguments that can't be NULL for the C functions. ........ r65134 | georg.brandl | 2008-07-19 14:46:12 +0200 (Sat, 19 Jul 2008) | 2 lines #3303: fix crash with invalid Py_DECREF in strcoll(). ........ r65135 | georg.brandl | 2008-07-19 15:00:22 +0200 (Sat, 19 Jul 2008) | 3 lines #3319: don't raise ZeroDivisionError if number of rounds is so low that benchtime is zero. ........ r65136 | georg.brandl | 2008-07-19 15:09:42 +0200 (Sat, 19 Jul 2008) | 3 lines #3323: mention that if inheriting from a class without __slots__, the subclass will have a __dict__ available too. ........ r65139 | georg.brandl | 2008-07-19 15:48:44 +0200 (Sat, 19 Jul 2008) | 2 lines Add ordering info for findall and finditer. ........ r65149 | raymond.hettinger | 2008-07-20 01:21:57 +0200 (Sun, 20 Jul 2008) | 1 line Fix compress() recipe in docs to use itertools. ........ r65150 | raymond.hettinger | 2008-07-20 01:58:47 +0200 (Sun, 20 Jul 2008) | 1 line Clean-up itertools docs and recipes. ........ r65151 | gregory.p.smith | 2008-07-20 02:22:08 +0200 (Sun, 20 Jul 2008) | 9 lines fix issue3120 - don't truncate handles on 64-bit Windows. This is still messy, realistically PC/_subprocess.c should never cast pointers to python numbers and back at all. I don't have a 64-bit windows build environment because microsoft apparently thinks that should cost money. Time to watch the buildbots. It builds and passes tests on 32-bit windows. ........ r65155 | georg.brandl | 2008-07-20 13:50:29 +0200 (Sun, 20 Jul 2008) | 2 lines #926501: add info where to put the docstring. ........ r65158 | neal.norwitz | 2008-07-20 21:35:23 +0200 (Sun, 20 Jul 2008) | 1 line Fix a couple of names in error messages that were wrong ........ r65159 | neal.norwitz | 2008-07-20 22:39:36 +0200 (Sun, 20 Jul 2008) | 1 line Fix misspeeld method name (negative) ........ r65176 | amaury.forgeotdarc | 2008-07-21 23:36:24 +0200 (Mon, 21 Jul 2008) | 4 lines Increment version number in NEWS file, and move items that were added after 2.6b2. (I thought there was a script to automate this kind of updates) ........ r65177 | amaury.forgeotdarc | 2008-07-22 00:00:38 +0200 (Tue, 22 Jul 2008) | 5 lines Issue2378: pdb would delete free variables when stepping into a class statement. The problem was introduced by r53954, the correction is to restore the symmetry between PyFrame_FastToLocals and PyFrame_LocalsToFast ........ r65178 | benjamin.peterson | 2008-07-22 00:05:34 +0200 (Tue, 22 Jul 2008) | 1 line don't use assert statement ........ r65183 | ronald.oussoren | 2008-07-22 09:06:00 +0200 (Tue, 22 Jul 2008) | 2 lines Fix buglet in fix for issue3381 ........ r65184 | ronald.oussoren | 2008-07-22 09:06:33 +0200 (Tue, 22 Jul 2008) | 2 lines Fix build issue on OSX 10.4, somehow this wasn't committed before. ........ r65187 | raymond.hettinger | 2008-07-22 20:54:02 +0200 (Tue, 22 Jul 2008) | 1 line Remove out-of-date section on Exact/Inexact. ........ r65188 | raymond.hettinger | 2008-07-22 21:00:47 +0200 (Tue, 22 Jul 2008) | 1 line Tuples now have both count() and index(). ........ r65189 | raymond.hettinger | 2008-07-22 21:03:05 +0200 (Tue, 22 Jul 2008) | 1 line Fix credits for math.sum() ........ r65190 | raymond.hettinger | 2008-07-22 21:18:50 +0200 (Tue, 22 Jul 2008) | 1 line One more attribution. ........ r65192 | benjamin.peterson | 2008-07-23 01:44:37 +0200 (Wed, 23 Jul 2008) | 1 line remove unneeded import ........ r65194 | benjamin.peterson | 2008-07-23 15:25:06 +0200 (Wed, 23 Jul 2008) | 1 line use isinstance ........
* Merged revisions 64226 via svnmerge fromMartin v. Löwis2008-06-131-1/+1
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r64226 | martin.v.loewis | 2008-06-13 09:47:47 +0200 (Fr, 13 Jun 2008) | 2 lines Make more symbols static. ........
* Implement PEP 3121: new module initialization and finalization API.Martin v. Löwis2008-06-111-3/+17
|
* Fix another buffer overflow.Martin v. Löwis2008-03-081-1/+1
|
* Fix typo in assertion.Martin v. Löwis2008-03-081-1/+1
|
* Properly size memory blocks in units of wchar_t.Martin v. Löwis2008-03-081-4/+4
|
* Use wchar_t functions in _locale module.Martin v. Löwis2008-03-081-42/+85
|
* Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases ↵Christian Heimes2007-12-021-12/+12
| | | | in intobject.h
* Get the locale and pwd tests working on the Solaris box where thereNeal Norwitz2007-10-271-2/+4
| | | | | are some unicode values used. I'm not sure if this is the correct on all operating systems, but this works on Linux w/o unicode.
* Use unicodeNeal Norwitz2007-08-261-39/+14
|
* Use a newer API for creating the module so we don't have to createNeal Norwitz2007-08-231-5/+1
| | | | | | the docstring manually. Saves code and a call to PyString_FromString. (There are still more calls to PyString_FromString.)
* Remove RISCOS supportSkip Montanaro2007-08-161-4/+0
|
* Don't mess with string.letters any more. It is most likely going to disappear.Guido van Rossum2007-08-131-62/+0
| | | | | Even if it isn't, it shouldn't be changed based on the locale setting IMO. (Incidentally, this makes test_csv.py pass again on my box.)
* Set sys.stdout.encoding properly.Martin v. Löwis2007-08-111-2/+3
| | | | | Always set LC_CTYPE on interpreter startup. Add device_encoding function.
* Merged revisions 55342-55406 via svnmerge fromGuido van Rossum2007-05-171-10/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/p3yk ........ r55360 | guido.van.rossum | 2007-05-15 14:57:59 -0700 (Tue, 15 May 2007) | 2 lines obcheckin. ........ r55361 | guido.van.rossum | 2007-05-15 14:59:18 -0700 (Tue, 15 May 2007) | 2 lines Get rid of strop module. ........ r55367 | brett.cannon | 2007-05-15 21:06:28 -0700 (Tue, 15 May 2007) | 2 lines Remove the 'pure' module. ........ r55369 | brett.cannon | 2007-05-15 21:07:31 -0700 (Tue, 15 May 2007) | 2 lines Remove the lib-old directory (already empty). ........ r55370 | neal.norwitz | 2007-05-15 21:30:40 -0700 (Tue, 15 May 2007) | 1 line Get rid of a bunch more references to strop ........ r55374 | brett.cannon | 2007-05-15 21:39:00 -0700 (Tue, 15 May 2007) | 2 lines Complete the removal of IRIX-specific modules. ........ r55379 | brett.cannon | 2007-05-15 22:31:54 -0700 (Tue, 15 May 2007) | 2 lines Update removed IRIX modules based on what is gone from removing plat-irix6. ........ r55388 | brett.cannon | 2007-05-16 14:34:52 -0700 (Wed, 16 May 2007) | 2 lines Clean up the docstring for the compiler resource. ........ r55406 | brett.cannon | 2007-05-17 11:05:37 -0700 (Thu, 17 May 2007) | 2 lines Remove BaseException.message (deprecated in Python 2.6). ........