Commit Graph

227 Commits

Author SHA1 Message Date
Nick Coghlan 4274609e18
bpo-32096: Ensure new embedding test can find the encodings module (GH-4566) 2017-11-26 14:19:13 +10:00
Victor Stinner 9e87e7776f
bpo-32096: Remove obj and mem from _PyRuntime (#4532)
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>
2017-11-24 12:09:24 +01:00
Victor Stinner f7e5b56c37
bpo-32030: Split Py_Main() into subfunctions (#4399)
* 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)
2017-11-15 15:48:08 -08:00
xdegaye 1588be66d7
bpo-28180: Fix the implementation of PEP 538 on Android (GH-4334) 2017-11-12 12:45:59 +01:00
Erik Bray 031c4bfadb bpo-31877: Add _Py_LegacyLocaleDetected and _PyCoerceLegacyLocale to pylifecycle.h (GH-4134)
Only declaring these as interns inside the CLI's main C module
caused build problems on some platforms (notably Cygwin), so
this switches them to a regular underscore prefixed "private" C
API declaration.
2017-10-27 19:46:03 +10:00
Serhiy Storchaka 13ad3b7a82 bpo-31462: Remove trailing whitespaces. (#3564) 2017-09-14 09:38:36 +03:00
Antoine Pitrou a6a4dc816d bpo-31370: Remove support for threads-less builds (#3385)
* Remove Setup.config
* Always define WITH_THREAD for compatibility.
2017-09-07 18:56:24 +02:00
Nick Coghlan 6ea4186de3 bpo-28180: Implementation for PEP 538 (#659)
- new PYTHONCOERCECLOCALE config setting
- coerces legacy C locale to C.UTF-8, C.utf8 or UTF-8 by default
- always uses C.UTF-8 on Android
- uses `surrogateescape` on stdin and stdout in the coercion
  target locales
- configure option to disable locale coercion at build time
- configure option to disable C locale warning at build time
2017-06-11 13:16:15 +10:00
Eric Snow d1c3c13fed bpo-30447: Fix/skip the subinterpreters test on some platforms. (#1791) 2017-05-24 17:19:47 -07:00
Eric Snow e377416c10 bpo-29102: Add a unique ID to PyInterpreterState. (#1639) 2017-05-22 19:46:40 -07:00
Steve Dower ea74f0cd4a Issue #24932: Use proper command line parsing in _testembed 2017-01-01 20:25:03 -08:00
Steve Dower a439191efa Fix some warnings from MSVC 2016-09-06 19:09:15 -07:00
Ned Deily 1cce732fcf Issue #27713: merge from 3.5 2016-08-19 22:13:14 -04:00
Ned Deily 17cfc86422 Issue #27713: Surpress spurious build warnings when updating importlib's
bootstrap files:
    Could not find platform dependent libraries <exec_prefix
    Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Patch by Xiang Zhang
2016-08-19 22:12:06 -04:00
Ned Deily 939231be0e Issue #27736: Improve the existing embedded interpreter init/fini test
by increasing the number of iterations.  That appears sufficient to
expose the ref count problem fixed in this issue.
Patch suggested by Xiang Zhang
2016-08-16 00:17:42 -04:00
Martin Panter abe4d52a1a Merge doc and comment fixes from 3.5 2016-04-19 23:23:16 +00:00
Martin Panter 8f26565ba9 Fix spelling (inital), grammar (may translates) in documentation, comments 2016-04-19 04:03:41 +00:00
Victor Stinner 34be807ca4 Add PYTHONMALLOC env var
Issue #26516:

* Add PYTHONMALLOC environment variable to set the Python memory
  allocators and/or install debug hooks.
* PyMem_SetupDebugHooks() can now also be used on Python compiled in release
  mode.
* The PYTHONMALLOCSTATS environment variable can now also be used on Python
  compiled in release mode. It now has no effect if set to an empty string.
* In debug mode, debug hooks are now also installed on Python memory allocators
  when Python is configured without pymalloc.
2016-03-14 12:04:26 +01:00
Victor Stinner 7172f507e1 Replace fpgetmask() with fedisableexcept()
Issue #24520: On FreeBSD, fpgetmask() was deprecated long time ago.
fedisableexcept() is now preferred.
2016-01-20 22:27:34 +01:00
Eric Snow 33507000c7 Remove an unnecessary flag. 2015-05-05 21:29:31 -06:00
Eric Snow 32439d6eb6 Issue #23911: Move path-based bootstrap code to a separate frozen module. 2015-05-02 19:15:18 -06:00
Victor Stinner e134a7fe36 Issue #23752: _Py_fstat() is now responsible to raise the Python exception
Add _Py_fstat_noraise() function when a Python exception is not welcome.
2015-03-30 10:09:31 +02:00
Serhiy Storchaka b48af340b9 Silenced minor GCC warnings. 2015-02-26 15:27:57 +02:00
Steve Dower f2f373f593 Issue #23152: Implement _Py_fstat() to support files larger than 2 GB on Windows.
fstat() may fail with EOVERFLOW on files larger than 2 GB because the file size type is an signed 32-bit integer.
2015-02-21 08:44:05 -08:00
Berker Peksag da8cef40e5 Issue #22934: Update the comment to mention Programs/_freeze_importlib.c. 2014-11-24 23:26:08 +02:00
Victor Stinner f6a271ae98 Issue #18395: Rename ``_Py_char2wchar()`` to :c:func:`Py_DecodeLocale`, rename
``_Py_wchar2char()`` to :c:func:`Py_EncodeLocale`, and document these
functions.
2014-08-01 12:28:48 +02:00
Nick Coghlan 973fe0ba7a Issue #18093: Factor out the programs that embed the runtime 2014-07-25 21:52:14 +10:00