Commit graph

1224 commits

Author SHA1 Message Date
Serhiy Storchaka 13badcbc60
bpo-32197: Try to fix a compiler error on OS X introduced in bpo-32030. (#4681)
* Revert "bpo-32030: _PyPathConfig_Init() sets home and program_name (#4673)"

This reverts commit af5a895073.

* Revert "bpo-32030: Fix config_get_program_name() on macOS (#4669)"

This reverts commit e23c06e2b0.

* Revert "bpo-32030: Add Python/pathconfig.c (#4668)"

This reverts commit 0ea395ae96.

* Revert "bpo-32030: Don't call _PyPathConfig_Fini() in Py_FinalizeEx() (#4667)"

This reverts commit ebac19dad6.

* Revert "bpo-32030: Fix Py_GetPath(): init program_name (#4665)"

This reverts commit 9ac3d88827.
2017-12-02 21:36:00 +02:00
Victor Stinner af5a895073
bpo-32030: _PyPathConfig_Init() sets home and program_name (#4673)
_PyPathConfig_Init() now also initialize home and program_name:

* Rename existing _PyPathConfig_Init() to _PyPathConfig_Calculate().
  Add a new _PyPathConfig_Init() function in pathconfig.c which
  handles the _Py_path_config variable and call
  _PyPathConfig_Calculate().
* Add home and program_name fields to _PyPathConfig.home
* _PyPathConfig_Init() now initialize home and program_name
  from main_config
* Py_SetProgramName(), Py_SetPythonHome() and Py_GetPythonHome() now
  calls Py_FatalError() on failure, instead of silently ignoring
  failures.
* config_init_home() now gets directly _Py_path_config.home to only
  get the value set by Py_SetPythonHome(), or NULL if
  Py_SetPythonHome() was not called.
* config_get_program_name() now gets directly
  _Py_path_config.program_name to only get the value set by
  Py_SetProgramName(), or NULL if Py_SetProgramName() was not called.
* pymain_init_python() doesn't call Py_SetProgramName() anymore,
  _PyPathConfig_Init() now always sets the program name
* Call _PyMainInterpreterConfig_Read() in
  pymain_parse_cmdline_envvars_impl() to control the memory allocator
* C API documentation: it's no more safe to call Py_GetProgramName()
  before Py_Initialize().
2017-12-02 10:11:32 +01:00
Victor Stinner 0ea395ae96
bpo-32030: Add Python/pathconfig.c (#4668)
* Factorize code from PC/getpathp.c and Modules/getpath.c to remove
  duplicated code
* rename pathconfig_clear() to _PyPathConfig_Clear()
* Inline _PyPathConfig_Fini() in pymain_impl() and then remove it,
  since it's a oneliner
2017-12-01 20:50:58 +01:00
Victor Stinner ebac19dad6
bpo-32030: Don't call _PyPathConfig_Fini() in Py_FinalizeEx() (#4667)
Changes:

* _PyPathConfig_Fini() cannot be called in Py_FinalizeEx().
  Py_Initialize() and Py_Finalize() can be called multiple times, but
  it must not "forget" parameters set by Py_SetProgramName(),
  Py_SetPath() or Py_SetPythonHome(), whereas _PyPathConfig_Fini()
  clear all these parameters.
* config_get_program_name() and calculate_program_full_path() now
  also decode paths using Py_DecodeLocale() to use the
  surrogateescape error handler, rather than decoding using
  mbstowcs() which is strict.
* Change _Py_CheckPython3() prototype: () => (void)
* Truncate a few lines which were too long
2017-12-01 20:09:52 +01:00
Victor Stinner 9ac3d88827
bpo-32030: Fix Py_GetPath(): init program_name (#4665)
* _PyMainInterpreterConfig_ReadEnv() now sets program_name from
  environment variables and pymain_parse_envvars() implements the
  falls back on argv[0].
* Remove _PyMain.program_name: use the program_name from
  _PyMainInterpreterConfig
* Move the Py_SetProgramName() call back to pymain_init_python(),
  just before _Py_InitializeCore().
* pathconfig_global_init() now also calls
  _PyMainInterpreterConfig_Read() to set program_name if it isn't set
  yet
* Cleanup PyCalculatePath: pass main_config to subfunctions to get
  directly fields from main_config (home, module_search_path_env and
  program_name)
2017-12-01 19:30:41 +01:00
Victor Stinner b64de46aae
bpo-32030: Cleanup "path config" code (#4663)
* Rename PyPathConfig structure to _PyPathConfig and move it to
  Include/internal/pystate.h
* Rename path_config to _Py_path_config
* _PyPathConfig: Rename program_name field to program_full_path
* Add assert(str != NULL); to _PyMem_RawWcsdup(), _PyMem_RawStrdup()
  and _PyMem_Strdup().
* Rename calculate_path() to pathconfig_global_init(). The function
  now does nothing if it's already initiallized.
2017-12-01 18:27:09 +01:00
Victor Stinner 9316ee4da2
bpo-32030: Add _PyPathConfig_Init() (#4551)
* 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
2017-11-25 03:17:57 +01:00
Victor Stinner f04ebe2a4d
bpo-32030: Add _PyMainInterpreterConfig.program_name (#4548)
* 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
2017-11-25 00:01:23 +01:00
Victor Stinner 46972b7bc3
bpo-32030: Add _PyMainInterpreterConfig_ReadEnv() (#4542)
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()
2017-11-24 22:55:40 +01:00
Berker Peksag 19fb134185
bpo-12239: Make GetProperty() return None for VT_EMPTY (GH-4539)
The previous behavior was to raise an exception

    NotImplementedError: result of type 0

when the value of the property is VT_EMPTY.
2017-11-24 18:11:18 +03:00
Berker Peksag 4864a619dc
bpo-12382: Make OpenDatabase() raise better exception messages (GH-4528)
Previously, 'msilib.OpenDatabase()' function raised a
cryptical exception message when it couldn't open or
create an MSI file. For example:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    _msi.MSIError: unknown error 6e
2017-11-24 12:53:58 +03:00
Victor Stinner 0327bde9da
bpo-32030: Rewrite calculate_path() (#4521)
* 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)
2017-11-23 17:03:20 +01:00
Berker Peksag bdb8315c21
bpo-1102: View.Fetch() now returns None when it's exhausted (GH-4459) 2017-11-23 15:47:30 +03:00
Victor Stinner 1f15111a6e
bpo-32030: Add _PyMainInterpreterConfig.pythonhome (#4513)
* 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
2017-11-23 10:43:14 +01:00
Victor Stinner e32e79f7d8
bpo-32030: Move PYTHONPATH to _PyMainInterpreterConfig (#4511)
Move _PyCoreConfig.module_search_path_env to _PyMainInterpreterConfig
structure.
2017-11-23 01:49:45 +01:00
Victor Stinner d434110974
bpo-32030: Add _PyCoreConfig.module_search_path_env (#4504)
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.
2017-11-23 00:12:09 +01:00
Serhiy Storchaka e2f92de6a9
Add the const qualifier to "char *" variables that refer to literal strings. (#4370) 2017-11-11 13:06:26 +02:00
Berker Peksag a935654f06
bpo-20486: Implement Database.Close() method in msilib (GH-4141) 2017-11-07 15:58:53 +03:00
Zackery Spytz cb04f75182 Fix a memory leak in _msi.c (#4127) 2017-11-07 02:03:09 -08:00
luzpaz a5293b4ff2 Fix miscellaneous typos (#4275) 2017-11-05 15:37:50 +02:00
xdegaye 56d1f5ca32 bpo-30697: Fix PyErr_NormalizeException() when no memory (GH-2327) 2017-10-26 15:09:06 +02:00
Masayuki Yamamoto 731e189014 bpo-25658: Implement PEP 539 for Thread Specific Storage (TSS) API (GH-1362)
See PEP 539 for details.

Highlights of changes:

- Add Thread Specific Storage (TSS) API
- Document the Thread Local Storage (TLS) API as deprecated
- Update code that used TLS API to use TSS API
2017-10-06 20:41:34 +10:00
Stefan Grönke f1502d097c bpo-31569: correct PCBuild/ case to PCbuild/ in build scripts and docs (GH-3711) 2017-09-25 17:58:10 +01:00
Serhiy Storchaka 13ad3b7a82 bpo-31462: Remove trailing whitespaces. (#3564) 2017-09-14 09:38:36 +03:00
Eric Snow fc1bf872e9 bpo-30860: Move windows.h include out of internal/*.h. (#3458)
PR #3397 introduced a large number of warnings to the Windows build. This patch fixes them.
2017-09-11 18:30:43 -07:00
Steve Dower af8d6b9072 Fixes reference leak (#3457) 2017-09-08 11:35:38 -07:00
Eric Snow 2ebc5ce42a bpo-30860: Consolidate stateful runtime globals. (#3397)
* group the (stateful) runtime globals into various topical structs
* consolidate the topical structs under a single top-level _PyRuntimeState struct
* add a check-c-globals.py script that helps identify runtime globals

Other globals are excluded (see globals.txt and check-c-globals.py).
2017-09-07 23:51:28 -06:00
Steve Dower 05f01d8525 bpo-30389 Adds detection of VS 2017 to distutils._msvccompiler (#1632) 2017-09-07 11:49:23 -07: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
Zachary Ware d01db1c2a2 bpo-31358: Pull zlib out of the repository (GH-3375)
Also enable building externals by default on Windows, use PCbuild\build.bat's -E option to disable it.
2017-09-06 17:29:37 -07:00
Zachary Ware 49ce74efe8 Remove all mention of Windows IA-64 support (GH-3389)
It was mostly removed long ago.
2017-09-06 15:45:25 -07:00
Segev Finer a80e985c49 bpo-9566: Change HANDLE argument parsing to unsigned in msvcrtmodule.c (#2904) 2017-07-26 20:15:18 -07:00
Segev Finer 679b566622 bpo-9566: Fix some Windows x64 compiler warnings (#2492)
* bpo-9566: Silence liblzma warnings

* bpo-9566: Silence tcl warnings

* bpo-9566: Silence tk warnings

* bpo-9566: Silence tix warnings

* bpo-9566: Fix some library warnings

* bpo-9566: Fix msvcrtmodule.c warnings

* bpo-9566: Silence _bz2 warnings

* bpo-9566: Fixed some _ssl warnings

* bpo-9566: Fix _msi warnings

* bpo-9566: Silence _ctypes warnings

* Revert "bpo-9566: Fixed some _ssl warnings"

This reverts commit a639001c94.

* bpo-9566: Also consider NULL as a possible error in HANDLE_return_converter

* bpo-9566: whitespace fixes
2017-07-26 15:17:57 -07:00
Antoine Pitrou f474c5a3f3 bpo-30946: Remove obsolete fallback code in readline module (#2738)
* Remove obsolete fallback code in readline module

* Add NEWS

* Remove obsolete include

* Fix macro on Windows
2017-07-18 17:05:03 +02:00
Segev Finer c40ad03bf2 bpo-30731: python.manifest fix (#2328)
bpo-30731: python.manifest fix
2017-07-13 21:34:42 +02:00
Serhiy Storchaka 6969eaf468 bpo-29464: Rename METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and make (#1955)
the bare METH_FASTCALL be used for functions with positional-only
parameters.
2017-07-03 21:20:15 +03:00
INADA Naoki 6b42eb1764 bpo-29585: Fix sysconfig.get_config_var("PYTHONFRAMEWORK") (GH-2483)
`PYTHONFRAMEWORK` is defined in `Makefile` and it shoulnd't be used
in `pyconfig.h`.

`sysconfig.py --generate-posix-vars` reads config vars from Makefile
and `pyconfig.h`.  Conflicting variables should be avoided.

Especially, string config variables in Makefile are unquoted, but
in `pyconfig.h` are keep quoted.  So it should be private (starts with
underscore).
2017-06-29 15:31:38 +09:00
Segev Finer 9f3bdcb643 bpo-23451: Fix socket deprecation warnings in socketmodule.c (#2318)
* bpo-23451: Fix WSASocket and WSADuplicateSocket deprecation warnings

* bpo-23451: Add backwards compatibility note about socket share/fromshare

* bpo-23451: Fixed `WSAAddressToString`/`WSAStringToAddress` deprecation warnings

* bpo-23451: Use `inet_pton`/`inet_ntop` instead of `WSAAddressToString`/`WSAStringToAddress`

* bpo-23451: Move `HAVE_INET_PTON` from _socket.vcxproj to pyconfig.h

* bpo-23451: Add SUPPRESS_DEPRECATED_CALL to socketmodule.c

* bpo-23451: Add a NEWS.d entry

* bpo-23451: Corrected NEWS.d entry
2017-06-28 13:51:00 -07:00
Steve (Gadget) Barnes 5b8f972e09 bpo-30362 : Add list options to launcher. (#1578)
* bpo-30362 Add list options to launcher.

* bpo-30362 Add list options to help message.

* To avoid possible later conflict with python replaced flags with --launcher-list and --launcher-list-paths

* bpo-30362 Changed flag to -0 as suggested on review.

* bpo-30362: Modified to default to not path for -0, -0p to dispaly path and append * to default

* bpo-30362: Modified to display list on required version not found.

* bpo-30362 add --list and --list-paths added back in following review by paul.moore

* bpo-30362 Cleaner handing of -0 & -0p by not calling exit directly per review by @zooba

* bpo-30362: Tidy up and add news & what's new

Removed commented out line of code in PC/launcher.c.
Added the results of using blurb to add details of bpo-30362 & bpo-30291.
Updated Doc/whatsnew/3.7.rst to add a Windows only section covering both tickets.

* bpo-30362 Resolve conflict in Doc/whatsnew/3.7.rst

* bpo-30362:Address Whitespace Issue in Doc\whatsnew\3.7.rst

* Shorten NEWS message for bpo-30362

* Shorten NEWS item for bpo-30291
2017-06-28 12:14:52 -07:00
Victor Stinner b01c574ad6 bpo-29585: Define PYTHONFRAMEWORK in PC/pyconfig.h (#2477)
* bpo-29585: Fix PC/pyconfig.h whitespaces

Run "make patchcheck".

* bpo-29585: Define PYTHONFRAMEWORK in PC/pyconfig.h

* site: Fix path separator in _get_path() on Windows
2017-06-28 18:34:42 +02:00
Serhiy Storchaka ccdc09ed1e Fix compiler warnings on Windows introduced in bpo-13617. (#2464) 2017-06-28 09:55:22 +03:00
Serhiy Storchaka f7eae0adfc [security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302)
Based on patch by Victor Stinner.

Add private C API function _PyUnicode_AsUnicode() which is similar to
PyUnicode_AsUnicode(), but checks for null characters.
2017-06-28 08:30:06 +03:00
Steve Dower 40a23e8899 bpo-30687: Fixes build scripts to find msbuild.exe and stop relying on vcvarsall.bat (#2252)
* Fixes build scripts to find msbuild.exe and stop relying on vcvarsall.bat
Also fixes bdist_wininst.vcxproj to use correct version in generated name.
2017-06-19 10:34:25 -07:00
Zachary Ware 6b6e687766 bpo-27425: Be more explicit in .gitattributes (GH-840)
Updates checked-in line endings on several files.
2017-06-10 14:58:42 -05:00
Sylvain 7445381c60 bpo-30600: Fix error messages (condition order in Argument Clinic) (#2051)
The function '_PyArg_ParseStack()' and
'_PyArg_UnpackStack' were failing (with error
"XXX() takes Y argument (Z given)") before
the function '_PyArg_NoStackKeywords()' was called.
Thus, the latter did not raise its more meaningful
error : "XXX() takes no keyword arguments".
2017-06-10 07:51:48 +03:00
Eric Snow e377416c10 bpo-29102: Add a unique ID to PyInterpreterState. (#1639) 2017-05-22 19:46:40 -07:00
Steve (Gadget) Barnes 870f6a11dd bpo-30291 Changes to launcher so as to allow py -3-32, -2.7-64, 3.10, etc.
bpo-30291 Changes to launcher so as to allow py -3-32, -2.7-64, 3.10, etc.
2017-05-12 16:21:26 -07:00
Serhiy Storchaka 55fe1ae970 bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
Serhiy Storchaka 0b3ec19225 Use NULL rather than 0. (#778)
There was few cases of using literal 0 instead of NULL in the context of
pointers.  While this was a legitimate C code, using NULL rather than 0 makes
the code clearer.
2017-03-23 17:53:47 +02:00
Serhiy Storchaka 4dadcd4ed7 bpo-26121: Use C library implementation for math functions erf() and erfc() on Windows. (#632) 2017-03-12 13:39:22 +02:00