summaryrefslogtreecommitdiff
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
...
* bpo-34567: pythoninfo gets coreconfig (GH-9043)Victor Stinner2018-09-032-3/+158
| | | | | | * Add _testcapi.get_coreconfig() to get the _PyCoreConfig of the interpreter * test.pythoninfo now gets the core configuration using _testcapi.get_coreconfig()
* bpo-34544: Fix setlocale() in pymain_read_conf() (GH-9041)Victor Stinner2018-09-031-2/+13
| | | | | | | | bpo-34485, bpo-34544: On some FreeBSD, nl_langinfo(CODESET) fails if LC_ALL or LC_CTYPE is set to an invalid locale name. Replace _Py_SetLocaleFromEnv(LC_CTYPE) with _Py_SetLocaleFromEnv(LC_ALL) to initialize properly locales. Partially revert commit 177d921c8c03d30daa32994362023f777624b10d.
* Minor improvement to code clarity (GH-9036)Raymond Hettinger2018-09-021-1/+1
| | | Make it clear that the n==0 case is included. Otherwise, you have to know that max==0.0 whenever n==0.
* closes bpo-34555: Fix incorrectly nested test for HAVE_LINUX_VM_SOCKETS_H ↵Thomas Herzog2018-09-011-24/+25
| | | | (GH-9016)
* Simplify vector_norm() by eliminating special cases in the main loop (GH-9006)Raymond Hettinger2018-08-311-22/+18
| | | The *max* value is no longer treated as a special case in the main loop. Besides making the main loop simpler and branchless, this also lets us relax the input restriction of *vec* to contain only non-negative values.
* bpo-34523: Use _PyCoreConfig instead of globals (GH-9005)Victor Stinner2018-08-301-9/+9
| | | | | Use the core configuration of the interpreter, rather than using global configuration variables. For example, replace Py_QuietFlag with core_config->quiet.
* bpo-34523: Support surrogatepass in locale codecs (GH-8995)Victor Stinner2018-08-291-0/+94
| | | | | | | | | | | | | | | | | | | | Add support for the "surrogatepass" error handler in PyUnicode_DecodeFSDefault() and PyUnicode_EncodeFSDefault() for the UTF-8 encoding. Changes: * _Py_DecodeUTF8Ex() and _Py_EncodeUTF8Ex() now support the surrogatepass error handler (_Py_ERROR_SURROGATEPASS). * _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx() now use the _Py_error_handler enum instead of "int surrogateescape" to pass the error handler. These functions now return -3 if the error handler is unknown. * Add unit tests on _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx() in test_codecs. * Rename get_error_handler() to _Py_GetErrorHandler() and expose it as a private function. * _freeze_importlib doesn't need config.filesystem_errors="strict" workaround anymore.
* bpo-34523: Py_DecodeLocale() use UTF-8 on Windows (GH-8998)Victor Stinner2018-08-291-2/+11
| | | | | | | Py_DecodeLocale() and Py_EncodeLocale() now use the UTF-8 encoding on Windows if Py_LegacyWindowsFSEncodingFlag is zero. pymain_read_conf() now sets Py_LegacyWindowsFSEncodingFlag in its loop, but restore its value at exit.
* bpo-34523: Add _PyCoreConfig.filesystem_encoding (GH-8963)Victor Stinner2018-08-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | _PyCoreConfig_Read() is now responsible to choose the filesystem encoding and error handler. Using Py_Main(), the encoding is now chosen even before calling Py_Initialize(). _PyCoreConfig.filesystem_encoding is now the reference, instead of Py_FileSystemDefaultEncoding, for the Python filesystem encoding. Changes: * Add filesystem_encoding and filesystem_errors to _PyCoreConfig * _PyCoreConfig_Read() now reads the locale encoding for the file system encoding. * PyUnicode_EncodeFSDefault() and PyUnicode_DecodeFSDefaultAndSize() now use the interpreter configuration rather than Py_FileSystemDefaultEncoding and Py_FileSystemDefaultEncodeErrors global configuration variables. * Add _Py_SetFileSystemEncoding() and _Py_ClearFileSystemEncoding() private functions to only modify Py_FileSystemDefaultEncoding and Py_FileSystemDefaultEncodeErrors in coreconfig.c. * _Py_CoerceLegacyLocale() now takes an int rather than _PyCoreConfig for the warning.
* bpo-34485, Windows: LC_CTYPE set to user preference (GH-8988)Victor Stinner2018-08-291-15/+4
| | | | | | | | | | | | | | On Windows, the LC_CTYPE is now set to the user preferred locale at startup: _Py_SetLocaleFromEnv(LC_CTYPE) is now called during the Python initialization. Previously, the LC_CTYPE locale was "C" at startup, but changed when calling setlocale(LC_CTYPE, "") or setlocale(LC_ALL, ""). pymain_read_conf() now also calls _Py_SetLocaleFromEnv(LC_CTYPE) to behave as _Py_InitializeCore(). Moreover, it doesn't save/restore the LC_ALL anymore. On Windows, standard streams like sys.stdout now always use surrogateescape error handler by default (ignore the locale).
* Improve commutativity of math.hypot() and math.dist() (GH-8984)Raymond Hettinger2018-08-281-13/+19
|
* bpo-34485: Add _Py_ClearStandardStreamEncoding() (GH-8982)Victor Stinner2018-08-291-1/+1
| | | | | | | | | | * Move Py_SetStandardStreamEncoding() from pylifecycle.c to coreconfig.c * Add _Py_ClearStandardStreamEncoding() private function. * pymain_free() now calls _Py_ClearStandardStreamEncoding(). * Add assertions add the end of _PyCoreConfig_Read() * _PyCoreConfig_Copy(): rename COPY_STR_ATTR() macro to COPY_WSTR_ATTR(). * Fix get_stdio_errors() indentation.
* bpo-34485: Fix _Py_InitializeCore() for C locale coercion (GH-8979)Victor Stinner2018-08-291-1/+3
| | | | | | | | * _Py_InitializeCore() now sets the LC_CTYPE locale to the user preferred locale before checking if the C locale should be coerced or not in _PyCoreConfig_Read(). * Fix pymain_read_conf(): remember if the C locale has been coerced when the configuration should be read again if the encoding has changed.
* 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).
* Fast path for exact floats in math.hypot() and math.dist() (GH-8949)Raymond Hettinger2018-08-261-9/+21
|
* Remove unneeded PyErr_Clear() in _winapi_SetNamedPipeHandleState_impl() ↵Zackery Spytz2018-08-261-2/+0
| | | | (GH-8281)
* bpo-34395: Don't free allocated memory on realloc fail in load_mark() in ↵Sergey Fedoseev2018-08-251-15/+5
| | | | _pickle.c. (GH-8788)
* Fix upsizing of marks stack in pickle module. (GH-8860)Sergey Fedoseev2018-08-251-1/+1
| | | Previously marks stack was upsized even there was space for additional item.
* bpo-13312: Avoid int underflow in time year. (GH-8912)Gregory P. Smith2018-08-241-0/+6
| | | Avoids an integer underflow in the time module's year handling code.
* closes bpo-34471: _datetime: Add missing NULL check to ↵Alexey Izbyshev2018-08-241-1/+4
| | | | | tzinfo_from_isoformat_results. (GH-8869) Reported by Svace static analyzer.
* bpo-34454: fix .fromisoformat() methods crashing on inputs with surrogate ↵Paul Ganssle2018-08-231-9/+72
| | | | | | | | | | | | | | | | | | | | code points (GH-8862) The current C implementations **crash** if the input includes a surrogate Unicode code point, which is not possible to encode in UTF-8. Important notes: 1. It is possible to pass a non-UTF-8 string as a separator to the `.isoformat()` methods. 2. The pure-Python `datetime.fromisoformat()` implementation accepts strings with a surrogate as the separator. In `datetime.fromisoformat()`, in the special case of non-UTF-8 separators, this implementation will take a performance hit by making a copy of the input string and replacing the separator with 'T'. Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru> Co-authored-by: Paul Ganssle <paul@ganssle.io>
* bpo-34412: Make signal.strsignal() work on HP-UX (GH-8786)Michael Osipov2018-08-231-2/+20
| | | | | | Introduce a configure check for strsignal(3) which defines HAVE_STRSIGNAL for signalmodule.c. Add some common signals on HP-UX. This change applies for Windows and HP-UX.
* bpo-34207: Fix pymain_read_conf() for UTF-8 Mode (GH-8868)Victor Stinner2018-08-231-0/+6
| | | | | bpo-34170, bpo-34207: pymain_read_conf() now sets Py_UTF8Mode to config->utf8_mode. pymain_read_conf() calls indirectly Py_DecodeLocale() and Py_EncodeLocale() which depend on Py_UTF8Mode.
* bpo-34462: Add missing NULL check to _copy_raw_string() (GH-8863)Alexey Izbyshev2018-08-221-1/+1
| | | | Reported by Svace static analyzer.
* bpo-2122: Make mmap.flush() behave same on all platforms (GH-8692)Berker Peksag2018-08-221-4/+7
| | | | | Previously, its behavior was platform-dependent and there was no error checking under Windows.
* bpo-34456: pickle: Add missing NULL check to save_global(). (GH-8851)Alexey Izbyshev2018-08-221-0/+2
| | | Reported by Svace static analyzer.
* bpo-34441: Fix ABC.__subclasscheck__ crash on classes with invalid ↵Alexey Izbyshev2018-08-201-0/+3
| | | | | | __subclasses__ (GH-8835) The missing NULL check was reported by Svace static analyzer.
* bpo-34419: selectmodule.c does not compile on HP-UX due to bpo-31938 (GH-8796)Michael Osipov2018-08-171-3/+1
| | | | | | Fix compile errors reported by HP aCC by fixing bugs introduced in 6dc57e2a20c which do not cause trouble on clang or GCC. Patch by Michael Osipov.
* bpo-34217: Use lowercase for windows headers (GH-8472)Erik Janssens2018-08-162-2/+2
|
* bpo-34395: Fix memory leaks caused by incautious usage of PyMem_Resize(). ↵Sergey Fedoseev2018-08-162-42/+22
| | | | (GH-8756)
* bpo-34384: Fix os.readlink() on Windows (GH-8740)Berker Peksag2018-08-151-59/+34
| | | | | | | | | os.readlink() now accepts path-like and bytes objects on Windows. Previously, support for path-like and bytes objects was only implemented on Unix. This commit also merges Unix and Windows implementations of os.readlink() in one function and adds basic unit tests to increase test coverage of the function.
* Minor code clean-up. Don't alter the input vector. Use variables instead. ↵Raymond Hettinger2018-08-121-4/+5
| | | | GH-8748
* Add more tests and assertions for math.hypot() and math.dist() (GH-8747)Raymond Hettinger2018-08-121-0/+1
|
* Factor-out common code. Also, optimize common cases by preallocating space ↵Raymond Hettinger2018-08-111-41/+56
| | | | | on the stack. GH-8738 Improves speed by 9 to 10ns per call.
* Replace straight addition with Kahan summation and move max to the end (GH-8727)Raymond Hettinger2018-08-111-20/+45
|
* Fixed inconsistency in string handling in the Task C implementation (GH-8717)Alex Grönholm2018-08-091-5/+9
|
* bpo-34270: Make it possible to name asyncio tasks (GH-8547)Alex Grönholm2018-08-082-9/+92
| | | Co-authored-by: Antti Haapala <antti.haapala@anttipatterns.com>
* Remove unneeded PyErr_Clear() calls after PyErr_Print(). (GH-8699)Zackery Spytz2018-08-071-3/+0
| | | | PyErr_Print() always clears the error indicator, so there is no need to call PyErr_Clear() immediately afterwards.
* bpo-34170: Fix pymain_run_file() (GH-8660)Victor Stinner2018-08-031-6/+6
| | | | | bpo-34170, bpo-34326: Fix pymain_run_file(): use PyRun_AnyFileExFlags(closeit=1) instead of calling fclose(fp) explicitly to close the input file before running the code.
* bpo-34301: Add _PyInterpreterState_Get() helper function (GH-8592)Victor Stinner2018-08-034-15/+14
| | | | sys_setcheckinterval() now uses a local variable to parse arguments, before writing into interp->check_interval.
* Fix docstring of Profiler class (GH-8651)INADA Naoki2018-08-031-2/+2
|
* bpo-34170: Cleanup pymain_run_filename() (GH-8631)Victor Stinner2018-08-021-85/+71
| | | | | | | * Inline pymain_run_file() and pymain_open_filename() into pymain_run_filename() * Created pymain_run_stdin() which is pymain_run_filename() with filename=NULL * Rename pymain_run_filename() to pymain_run_file()
* bpo-34287: Do not use second argument of METH_NOARGS functions (GH-8582)jdemeyer2018-08-021-21/+21
|
* bpo-31650: Remove _Py_CheckHashBasedPycsMode global config var (GH-8608)Victor Stinner2018-08-011-3/+3
| | | | | | | | bpo-31650, bpo-34170: Replace _Py_CheckHashBasedPycsMode with _PyCoreConfig._check_hash_pycs_mode. Modify PyInit__imp() and zipimport to get the parameter from the current interpreter core configuration. Remove Include/internal/import.h file.
* bpo-34170: Add Python/coreconfig.c for _PyCoreConfig (GH-8607)Victor Stinner2018-08-011-910/+13
| | | | | | | * Add Include/coreconfig.h * Move config_*() and _PyCoreConfig_*() functions from Modules/main.c to a new Python/coreconfig.c file. * Inline _Py_ReadHashSeed() into config_init_hash_seed() * Move global configuration variables to coreconfig.c
* bpo-33499: Fix pymain_init_pycache_prefix() (GH-8596)Victor Stinner2018-08-011-10/+10
| | | | Fix a memory leak in pymain_init_pycache_prefix() when PYTHONPYCACHEPREFIX and -X pycache_prefix are used.
* bpo-34170: _PyCoreConfig_Read() defaults to argc=0 (GH-8595)Victor Stinner2018-08-011-0/+3
| | | Add unit tests for argc and argv of _PyCoreConfig.
* bpo-34170: Rename _PyCoreConfig.unbuffered_stdip (GH-8594)Victor Stinner2018-08-011-11/+16
| | | | * Rename _PyCoreConfig.unbuffered_stdio to buffered_stdio * Rename _PyCoreConfig.debug to parser_debug
* bpo-34170: Py_Main() updates config when setting Py_InspectFlag (GH-8593)Victor Stinner2018-08-011-0/+3
|
* bpo-34170: Add _PyCoreConfig._frozen parameter (GH-8591)Victor Stinner2018-08-012-3/+8
| | | Modify frozenmain.c to use _Py_InitializeFromConfig().