summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* bpo-20891: Fix PyGILState_Ensure() (#4650)Victor Stinner2017-11-301-6/+18
| | | | | | | When PyGILState_Ensure() is called in a non-Python thread before PyEval_InitThreads(), only call PyEval_InitThreads() after calling PyThreadState_New() to fix a crash. Add an unit test in test_embed.
* bpo-32030: Fix _Py_InitializeEx_Private() (#4649)Victor Stinner2017-11-301-6/+13
| | | | | _Py_InitializeEx_Private() now calls _PyMainInterpreterConfig_ReadEnv() to read environment variables PYTHONHOME and PYTHONPATH, and set the program name.
* bpo-32101: Add PYTHONDEVMODE environment variable (#4624)Victor Stinner2017-11-301-1/+4
| | | | | | * bpo-32101: Add sys.flags.dev_mode flag Rename also the "Developer mode" to the "Development mode". * bpo-32101: Add PYTHONDEVMODE environment variable Mention it in the development chapiter.
* bpo-32030: Rework memory allocators (#4625)Victor Stinner2017-11-292-8/+20
| | | | | | | | | | | | | | | | | | | | * Fix _PyMem_SetupAllocators("debug"): always restore allocators to the defaults, rather than only caling _PyMem_SetupDebugHooks(). * Add _PyMem_SetDefaultAllocator() helper to set the "default" allocator. * Add _PyMem_GetAllocatorsName(): get the name of the allocators * main() now uses debug hooks on memory allocators if Py_DEBUG is defined, rather than calling directly malloc() * Document default memory allocators in C API documentation * _Py_InitializeCore() now fails with a fatal user error if PYTHONMALLOC value is an unknown memory allocator, instead of failing with a fatal internal error. * Add new tests on the PYTHONMALLOC environment variable * Add support.with_pymalloc() * Add the _testcapi.WITH_PYMALLOC constant and expose it as support.with_pymalloc(). * sysconfig.get_config_var('WITH_PYMALLOC') doesn't work on Windows, so replace it with support.with_pymalloc(). * pythoninfo: add _testcapi collector for pymem
* bpo-32150: Expand tabs to spaces in C files. (#4583)Serhiy Storchaka2017-11-286-27/+27
|
* bpo-27535: Fix memory leak with warnings ignore (#4489)Victor Stinner2017-11-271-4/+9
| | | | | | | The warnings module doesn't leak memory anymore in the hidden warnings registry for the "ignore" action of warnings filters. The warn_explicit() function doesn't add the warning key to the registry anymore for the "ignore" action.
* bpo-32089: Use default action for ResourceWarning (#4584)Victor Stinner2017-11-271-3/+2
| | | | | In development and debug mode, use the "default" action, rather than the "always" action, for ResourceWarning in the default warnings filters.
* mark fatal_error as noreturn (#4563)Benjamin Peterson2017-11-251-1/+1
| | | | | | | | | | clang can't figure out that fatal_error is noreturn itself and emits warnings: ../cpython/Python/pylifecycle.c:2116:1: warning: function declared 'noreturn' should not return [-Winvalid-noreturn] } ^ ../cpython/Python/pylifecycle.c:2125:1: warning: function declared 'noreturn' should not return [-Winvalid-noreturn] } ^
* bpo-32030: Add _PyPathConfig_Init() (#4551)Victor Stinner2017-11-251-9/+19
| | | | | | | | | | | | | | * Add _PyPathConfig_Init() and _PyPathConfig_Fini() * Remove _Py_GetPathWithConfig() * _PyPathConfig_Init() returns _PyInitError to allow to handle errors properly * Add pathconfig_clear() * Windows calculate_path_impl(): replace Py_FatalError() with _PyInitError * Py_FinalizeEx() now calls _PyPathConfig_Fini() to release memory * Fix _Py_InitializeMainInterpreter() regression: don't initialize path config if _disable_importlib is false * PyPathConfig now uses dynamically allocated memory
* bpo-32030: Add _PyMainInterpreterConfig.program_name (#4548)Victor Stinner2017-11-241-4/+18
| | | | | | * Py_Main() now calls Py_SetProgramName() earlier to be able to get the program name in _PyMainInterpreterConfig_ReadEnv(). * Rename prog to program_name * Rename progpath to program_name
* bpo-32030: Add _PyMainInterpreterConfig_ReadEnv() (#4542)Victor Stinner2017-11-241-26/+19
| | | | | | | | | | | | | | | | | | Py_GetPath() and Py_Main() now call _PyMainInterpreterConfig_ReadEnv() to share the same code to get environment variables. Changes: * Add _PyMainInterpreterConfig_ReadEnv() * Add _PyMainInterpreterConfig_Clear() * Add _PyMem_RawWcsdup() * _PyMainInterpreterConfig: rename pythonhome to home * Rename _Py_ReadMainInterpreterConfig() to _PyMainInterpreterConfig_Read() * Use _Py_INIT_USER_ERR(), instead of _Py_INIT_ERR(), for decoding errors: the user is able to fix the issue, it's not a bug in Python. Same change was made in _Py_INIT_NO_MEMORY(). * Remove _Py_GetPythonHomeWithConfig()
* bpo-32125: Remove Py_UseClassExceptionsFlag flag (#4544)Victor Stinner2017-11-241-1/+0
| | | This flag was deprecated and wasn't used anymore since Python 2.0.
* bpo-32096: Remove obj and mem from _PyRuntime (#4532)Victor Stinner2017-11-241-2/+0
| | | | | | | | | | | | | | | | | bpo-32096, bpo-30860: Partially revert the commit 2ebc5ce42a8a9e047e790aefbf9a94811569b2b6: * Move structures back from Include/internal/mem.h to Objects/obmalloc.c * Remove _PyObject_Initialize() and _PyMem_Initialize() * Remove Include/internal/pymalloc.h * Add test_capi.test_pre_initialization_api(): Make sure that it's possible to call Py_DecodeLocale(), and then call Py_SetProgramName() with the decoded string, before Py_Initialize(). PyMem_RawMalloc() and Py_DecodeLocale() can be called again before _PyRuntimeState_Init(). Co-Authored-By: Eric Snow <ericsnowcurrently@gmail.com>
* bpo-27535: Cleanup create_filter() (#4516)Victor Stinner2017-11-231-38/+18
| | | | | create_filter() now expects the action as a _Py_Identifier which avoids string comparison, and more important, to avoid handling the "unknown action" annoying case.
* bpo-32030: Rewrite calculate_path() (#4521)Victor Stinner2017-11-231-8/+17
| | | | | | | | | | | | | | | | | * calculate_path() rewritten in Modules/getpath.c and PC/getpathp.c * Move global variables into a new PyPathConfig structure. * calculate_path(): * Split the huge calculate_path() function into subfunctions. * Add PyCalculatePath structure to pass data between subfunctions. * Document PyCalculatePath fields. * Move cleanup code into a new calculate_free() subfunction * calculate_init() now handles Py_DecodeLocale() failures properly * calculate_path() is now atomic: only replace PyPathConfig (path_config) at once on success. * _Py_GetPythonHomeWithConfig() now returns an error on failure * Add _Py_INIT_NO_MEMORY() helper: report a memory allocation failure * Coding style fixes (PEP 7)
* bpo-32030: Add _PyMainInterpreterConfig.pythonhome (#4513)Victor Stinner2017-11-232-20/+49
| | | | | | | | | | | | * Py_Main() now reads the PYTHONHOME environment variable * Add _Py_GetPythonHomeWithConfig() private function * Add _PyWarnings_InitWithConfig() * init_filters() doesn't get the current core configuration from the current interpreter or Python thread anymore. Pass explicitly the configuration to _PyWarnings_InitWithConfig(). * _Py_InitializeCore() now fails on _PyWarnings_InitWithConfig() failure. * Pass configuration as constant
* bpo-32030: Move PYTHONPATH to _PyMainInterpreterConfig (#4511)Victor Stinner2017-11-231-2/+2
| | | | Move _PyCoreConfig.module_search_path_env to _PyMainInterpreterConfig structure.
* bpo-32030: Add _PyCoreConfig.module_search_path_env (#4504)Victor Stinner2017-11-222-47/+54
| | | | | | | | | | | Changes: * Py_Main() initializes _PyCoreConfig.module_search_path_env from the PYTHONPATH environment variable. * PyInterpreterState_New() now initializes core_config and config fields * Compute sys.path a little bit ealier in _Py_InitializeMainInterpreter() and new_interpreter() * Add _Py_GetPathWithConfig() private function.
* bpo-27535: Optimize warnings.warn() (#4508)Victor Stinner2017-11-221-42/+33
| | | | | | | | | | | | | * Optimize warnings.filterwarnings(). Replace re.compile('') with None to avoid the cost of calling a regex.match() method, whereas it always matchs. * Optimize get_warnings_attr(): replace PyObject_GetAttrString() with _PyObject_GetAttrId(). Cleanup also create_filter(): * Use _Py_IDENTIFIER() to allow to cleanup strings at Python finalization * Replace Py_FatalError() with a regular exceptions
* bpo-32030: Add more options to _PyCoreConfig (#4485)Victor Stinner2017-11-213-11/+11
| | | | | | Py_Main() now handles two more -X options: * -X showrefcount: new _PyCoreConfig.show_ref_count field * -X showalloccount: new _PyCoreConfig.show_alloc_count field
* bpo-32089: Fix warnings filters in dev mode (#4482)Victor Stinner2017-11-211-10/+27
| | | | | | | | | | The developer mode (-X dev) now creates all default warnings filters to order filters in the correct order to always show ResourceWarning and make BytesWarning depend on the -b option. Write a functional test to make sure that ResourceWarning is logged twice at the same location in the developer mode. Add a new 'dev_mode' field to _PyCoreConfig.
* bpo-32088: Display Deprecation in debug mode (#4474)Victor Stinner2017-11-201-0/+7
| | | | | | | | When Python is build is debug mode (Py_DEBUG), DeprecationWarning, PendingDeprecationWarning and ImportWarning warnings are now displayed by default. test_venv: run "-m pip" and "-m ensurepip._uninstall" with -W ignore::DeprecationWarning since pip code is not part of Python.
* bpo-32043: New "developer mode": "-X dev" option (#4413)Victor Stinner2017-11-161-0/+8
| | | | | | | | | | | | | Add a new "developer mode": new "-X dev" command line option to enable debug checks at runtime. Changes: * Add unit tests for -X dev * test_cmd_line: replace test.support with support. * Fix _PyRuntimeState_Fini(): Use the same memory allocator than _PyRuntimeState_Init(). * Fix _PyMem_GetDefaultRawAllocator()
* bpo-32030: Enhance Py_Main() (#4412)Victor Stinner2017-11-164-120/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Parse more env vars in Py_Main(): * Add more options to _PyCoreConfig: * faulthandler * tracemalloc * importtime * Move code to parse environment variables from _Py_InitializeCore() to Py_Main(). This change fixes a regression from Python 3.6: PYTHONUNBUFFERED is now read before calling pymain_init_stdio(). * _PyFaulthandler_Init() and _PyTraceMalloc_Init() now take an argument to decide if the module has to be enabled at startup. * tracemalloc_start() is now responsible to check the maximum number of frames. Other changes: * Cleanup Py_Main(): * Rename some pymain_xxx() subfunctions * Add pymain_run_python() subfunction * Cleanup Py_NewInterpreter() * _PyInterpreterState_Enable() now reports failure * init_hash_secret() now considers pyurandom() failure as an "user error": don't fail with abort(). * pymain_optlist_append() and pymain_strdup() now sets err on memory allocation failure.
* bpo-32030: Split Py_Main() into subfunctions (#4399)Victor Stinner2017-11-156-211/+396
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Don't use "Python runtime" anymore to parse command line options or to get environment variables: pymain_init() is now a strict separation. * Use an error message rather than "crashing" directly with Py_FatalError(). Limit the number of calls to Py_FatalError(). It prepares the code to handle errors more nicely later. * Warnings options (-W, PYTHONWARNINGS) and "XOptions" (-X) are now only added to the sys module once Python core is properly initialized. * _PyMain is now the well identified owner of some important strings like: warnings options, XOptions, and the "program name". The program name string is now properly freed at exit. pymain_free() is now responsible to free the "command" string. * Rename most methods in Modules/main.c to use a "pymain_" prefix to avoid conflits and ease debug. * Replace _Py_CommandLineDetails_INIT with memset(0) * Reorder a lot of code to fix the initialization ordering. For example, initializing standard streams now comes before parsing PYTHONWARNINGS. * Py_Main() now handles errors when adding warnings options and XOptions. * Add _PyMem_GetDefaultRawAllocator() private function. * Cleanup _PyMem_Initialize(): remove useless global constants: move them into _PyMem_Initialize(). * Call _PyRuntime_Initialize() as soon as possible: _PyRuntime_Initialize() now returns an error message on failure. * Add _PyInitError structure and following macros: * _Py_INIT_OK() * _Py_INIT_ERR(msg) * _Py_INIT_USER_ERR(msg): "user" error, don't abort() in that case * _Py_INIT_FAILED(err)
* bpo-30950: Convert round() to Argument Clinic. (#2740)Serhiy Storchaka2017-11-152-20/+51
|
* bpo-32011: Revert "Issue #15480: Remove the deprecated and unused TYPE_INT64 ↵Serhiy Storchaka2017-11-151-0/+21
| | | | | | | code from marshal." (#4381) Simplify the reverted code. This reverts commit e9bbe8b87ba2874efba0474af5cc7d5941dbf742.
* bpo-32023: Disallow genexprs without parenthesis in class definitions. (#4400)Serhiy Storchaka2017-11-151-5/+10
|
* bpo-31949: Fixed several issues in printing tracebacks ↵Serhiy Storchaka2017-11-151-51/+51
| | | | | | | | | | | | (PyTraceBack_Print()). (#4289) * Setting sys.tracebacklimit to 0 or less now suppresses printing tracebacks. * Setting sys.tracebacklimit to None now causes using the default limit. * Setting sys.tracebacklimit to an integer larger than LONG_MAX now means using the limit LONG_MAX rather than the default limit. * Fixed integer overflows in the case of more than 2**31 traceback items on Windows. * Fixed output errors handling.
* bpo-32012: Disallow trailing comma after genexpr without parenthesis. (#4382)Serhiy Storchaka2017-11-151-10/+9
|
* bpo-30696: Fix the REPL looping endlessly when no memory (GH-4160)xdegaye2017-11-121-18/+42
|
* bpo-28180: Fix the implementation of PEP 538 on Android (GH-4334)xdegaye2017-11-121-12/+65
|
* bpo-31572: Get rid of _PyObject_HasAttrId() in the ASDL parser. (#3725)Serhiy Storchaka2017-11-111-610/+774
| | | Silence only expected AttributeError.
* bpo-31572: Don't silence unexpected errors in the _warnings module. (#3731)Serhiy Storchaka2017-11-111-68/+89
| | | | | Get rid of _PyObject_HasAttrId() and PyDict_GetItemString(). Silence only expected AttributeError, KeyError and ImportError when get an attribute, look up in a dict or import a module.
* Add the const qualifier to "char *" variables that refer to literal strings. ↵Serhiy Storchaka2017-11-115-5/+6
| | | | (#4370)
* Replace KB unit with KiB (#4293)Victor Stinner2017-11-083-7/+7
| | | | | | | | | | | kB (*kilo* byte) unit means 1000 bytes, whereas KiB ("kibibyte") means 1024 bytes. KB was misused: replace kB or KB with KiB when appropriate. Same change for MB and GB which become MiB and GiB. Change the output of Tools/iobench/iobench.py. Round also the size of the documentation from 5.5 MB to 5 MiB.
* bpo-31415: Improve error handling and caching of the importtime option. (#4138)Serhiy Storchaka2017-11-071-13/+20
|
* Fix miscellaneous typos (#4275)luzpaz2017-11-053-3/+3
|
* bpo-28994: PyErr_NormalizeException() no longer use C stack for recursion. ↵Serhiy Storchaka2017-11-051-39/+33
| | | | | (#2035) MemoryError raised when normalizing a RecursionError raised during exception normalization now not always causes a fatal error.
* bpo-31415: Support PYTHONPROFILEIMPORTTIME envvar equivalent to -X ↵Barry Warsaw2017-11-021-4/+11
| | | | | | importtime (#4240) Support PYTHONPROFILEIMPORTTIME envvar equivalent to -X importtime
* bpo-31784: Implement PEP 564: add time.time_ns() (#3989)Victor Stinner2017-11-021-19/+86
| | | | | | | | | | | | | | | | | | | | | | | | | Add new time functions: * time.clock_gettime_ns() * time.clock_settime_ns() * time.monotonic_ns() * time.perf_counter_ns() * time.process_time_ns() * time.time_ns() Add new _PyTime functions: * _PyTime_FromTimespec() * _PyTime_FromNanosecondsObject() * _PyTime_FromTimeval() Other changes: * Add also os.times() tests to test_os. * pytime_fromtimeval() and pytime_fromtimeval() now return _PyTime_MAX or _PyTime_MIN on overflow, rather than undefined behaviour * _PyTime_FromNanoseconds() parameter type changes from long long to _PyTime_t
* bpo-28936: Detect lexically first syntax error first (#4097)Ivan Levkivskyi2017-10-261-18/+16
| | | | Lexically first global and nonlocal syntax errors at given scope should be detected first.
* Fix trailing whitespaces in C files. (#4130)Serhiy Storchaka2017-10-261-1/+1
|
* bpo-30697: Fix PyErr_NormalizeException() when no memory (GH-2327)xdegaye2017-10-261-16/+30
|
* bpo-21720: Restore the Python 2.7 logic in handling a fromlist. (#4118)Serhiy Storchaka2017-10-261-1773/+1783
| | | | | | BytesWarning no longer emitted when the fromlist argument of __import__() or the __all__ attribute of the module contain bytes instances.
* bpo-31857: Make the behavior of USE_STACKCHECK deterministic (#4098)pdox2017-10-262-1/+4
|
* remove support for splitting the ceval switch into multiple switches (#4099)Benjamin Peterson2017-10-251-10/+0
| | | | | | | This kludge is from 1992. Any C99 compiler is going to be able to handle the ceval dispatch switch. Anyway, we have much bigger switches than the ceval dispatch one around. (See, e.g., Objects/unicodetype_db.h.)
* bpo-31845: Fix reading flags from environment (GH-4105)Nick Coghlan2017-10-251-14/+23
| | | | | | | | | | The startup refactoring means command line settings are now applied after settings are read from the environment. This updates the way command line settings are applied to account for that, ensures more settings are first read from the environment in _PyInitializeCore, and adds a simple test case covering the flags that are easy to check.
* bpo-30768: Recompute timeout on interrupted lock (GH-4103)Victor Stinner2017-10-242-10/+54
| | | | | | | | | | | | | | | | Fix the pthread+semaphore implementation of PyThread_acquire_lock_timed() when called with timeout > 0 and intr_flag=0: recompute the timeout if sem_timedwait() is interrupted by a signal (EINTR). See also the PEP 475. The pthread implementation of PyThread_acquire_lock() now fails with a fatal error if the timeout is larger than PY_TIMEOUT_MAX, as done in the Windows implementation. The check prevents any risk of overflow in PyThread_acquire_lock(). Add also PY_DWORD_MAX constant.
* bpo-30817: Fix PyErr_PrintEx() when no memory (#2526)xdegaye2017-10-231-3/+9
|