classification
Title: 32-bit 2.7.11 installer creates registry keys that are incompatible with the installed python27.dll
Type: behavior Stage: resolved
Components: Build, Windows Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: steve.dower Nosy List: Christian Brabandt, Zbynek.Winkler, aundro, benjamin.peterson, eryksun, micbou, paul.moore, pfeil, python-dev, steve.dower, tim.golden, zach.ware
Priority: release blocker Keywords:

Created on 2015-12-08 14:16 by aundro, last changed 2016-03-23 18:42 by Zbynek.Winkler. This issue is now closed.

Messages (11)
msg256113 - (view) Author: Arnaud Diederen (aundro) Date: 2015-12-08 14:16
[First of all let me say I'm not all that familiar with Windows, so please let me know if the wording in my analysis below is not clear and/or misleading.]

It would appear the 32-bit installer for Python 2.7.11 creates the registry key:
---
HKLM\Software\Wow6432Node\Python\PythonCore\2.7\PythonPath
---
(...just like previous 2.7 versions did.)

However, registry accesses (PC/getpathp.c's getpythonpath()) are done like so:
---
    (...)
    keyBuf = keyBufPtr = PyMem_RawMalloc(keyBufLen);
    if (keyBuf==NULL) goto done;

    memcpy_s(keyBufPtr, keyBufLen, keyPrefix, sizeof(keyPrefix)-sizeof(WCHAR));
    keyBufPtr += Py_ARRAY_LENGTH(keyPrefix) - 1;
    mbstowcs(keyBufPtr, PyWin_DLLVersionString, versionLen);
    (...)
---
where 'PyWin_DLLVersionString' now is "2.7-32":
---
.rsrc:1E2760FA                 unicode 0, <2.7-32>,0
---
(it used to be "2.7" in previous versions) 


Thus, the key that python27.dll builds is:
 HKLM\Software\Wow6432Node\Python\PythonCore\2.7-32\PythonPath
and not
 HKLM\Software\Wow6432Node\Python\PythonCore\2.7\PythonPath

and consequently the runtime cannot build a proper sys.path, which causes embedded interpreters to fail loading core modules.

As a workaround, it seems renaming the registry key to its "-32"-suffixed name, does help.
msg256116 - (view) Author: Eryk Sun (eryksun) * Date: 2015-12-08 15:28
Issue 24508 backported the project files from 3.5 to 2.7. In the new pyproject.props, MS_DLL_ID (for the DLL string table) is defined as the value of SysWinVer. Currently the latter is defined in python.props as follows:

    <!-- The version number for sys.winver -->
    <SysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)</SysWinVer>
    <SysWinVer Condition="$(Platform) == 'Win32' or $(Platform) == 'x86'">$(SysWinVer)-32</SysWinVer>

AFAIK, 2.7 shouldn't be using the -32 suffix for 32-bit builds. This should only have changed for 3.5+.
msg256119 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2015-12-08 16:11
Eryk is correct, there should be no -32 suffix in 2.7.  It's simple enough to fix, just remove the last line Eryk quoted (and purge generated files from PC/).

This is a pretty major bug; Benjamin and Steve, how do you want to deal with it?
msg256122 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-12-08 18:42
Needs a new release - up to Ben whether it's .12 or just a new .11. I can do the build today or this weekend, but not in between.
msg256139 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2015-12-09 05:59
I don't really have the time to cut a new release in the next few weeks.

On Tue, Dec 8, 2015, at 10:42, Steve Dower wrote:
> 
> Steve Dower added the comment:
> 
> Needs a new release - up to Ben whether it's .12 or just a new .11. I can
> do the build today or this weekend, but not in between.
> 
> ----------
> 
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue25824>
> _______________________________________
msg256500 - (view) Author: Michel Bouard (micbou) Date: 2015-12-16 01:37
This issue specifically talks about the 32-bit installer but the 64-bit is also affected by it.

It is the same workaround but with a different registry key:

  HKLM\Software\Python\PythonCore\2.7

renamed to

  HKLM\Software\Python\PythonCore\2.7-32
msg256505 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-12-16 03:06
64-bit Python shouldn't have the -32 in sys.winver, so it isn't affected. (If it does have the suffix, we have a second issue, but since it'd also be fixed by removing the code Eryk quoted there's no need for another issue.)
msg256512 - (view) Author: Michel Bouard (micbou) Date: 2015-12-16 07:09
In a interactive shell:

$ python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.winver
'2.7-32'
>>>

I agree that this is the same fix but I think the title should be updated.
msg257176 - (view) Author: Christian Brabandt (Christian Brabandt) Date: 2015-12-29 12:42
Note this issue breaks Vim compiled with python support (issue: https://github.com/vim/vim/issues/526) and ci.appveyor.com tests (e.g. https://ci.appveyor.com/project/chrisbra/vim/build/211)
msg257698 - (view) Author: Stefan Pfeil (pfeil) Date: 2016-01-07 16:26
Our installations of Python Essentials for SPSS Statistics 21 (64bit, presumeably also 32bit) were also broken by this issue (Python Essentials for SPSS 21 uses the regular Python 2.7 folder/installation).

The workaround with renaming the mentioned registry key works here as well (we still decided to hold back the update to Python 2.7.11 for the moment).
msg258417 - (view) Author: Roundup Robot (python-dev) Date: 2016-01-16 21:42
New changeset b91c323a605e by Steve Dower in branch '2.7':
Issue #25824: Fixes sys.winver to not include any architecture suffix.
https://hg.python.org/cpython/rev/b91c323a605e
History
Date User Action Args
2016-05-13 15:46:12steve.dowerlinkissue26998 superseder
2016-03-23 18:42:06Zbynek.Winklersetnosy: + Zbynek.Winkler
2016-01-22 14:02:55eryksunlinkissue26108 superseder
2016-01-16 21:42:40steve.dowersetstatus: open -> closed
assignee: steve.dower
resolution: fixed
stage: resolved
2016-01-16 21:42:06python-devsetnosy: + python-dev
messages: + msg258417
2016-01-07 16:26:16pfeilsetmessages: + msg257698
2016-01-07 16:18:30pfeilsetnosy: + pfeil
2015-12-29 12:42:08Christian Brabandtsetnosy: + Christian Brabandt
messages: + msg257176
2015-12-16 07:09:09micbousetmessages: + msg256512
2015-12-16 03:06:27steve.dowersetmessages: + msg256505
2015-12-16 01:37:34micbousetnosy: + micbou
messages: + msg256500
2015-12-09 05:59:08benjamin.petersonsetmessages: + msg256139
2015-12-08 18:42:40steve.dowersetmessages: + msg256122
2015-12-08 16:11:45zach.waresetpriority: normal -> release blocker

nosy: + benjamin.peterson
messages: + msg256119

components: + Build, - Installation
2015-12-08 15:34:07zach.waresetnosy: + paul.moore, tim.golden, zach.ware, steve.dower
components: + Windows
2015-12-08 15:28:57eryksunsetnosy: + eryksun
messages: + msg256116
2015-12-08 14:16:40aundrocreate