[issue31172] Py_Main() is totally broken on Visual Studio 2017

2017-08-10 Thread Patrick Rutkowski

New submission from Patrick Rutkowski:

Install Visual Studio 2017

Download and unpack Python-3.6.2.tgz

Open a Visual Studio command prompt
Browse to Python-3.6.2\PCBuild
Run build.bat -p x64 -c Release
Run build.bat -p x64 -c Debug
Add the PCbuild\amd64 directory to your PATH

Create a new Visual Studio Win32 GUI project called mypythonw

Copy-paste the source code of Python-3.6.2\PCBuild\WinMain.c into your mypthonw 
project.

Add Python-3.6.2\Include and Python-3.6.2\PC to mypythonw's include path.

Add Python-3.6.2\PCbuild\amd64 to mypythonw's library search path

Build mypthonw

Run these two commands:

pythonw -c "import ctypes; ctypes.windll.user32.MessageBoxW(0, 'Hello World!', 
'Hello', 0)

mypythonw -c "import ctypes; ctypes.windll.user32.MessageBoxW(0, 'Hello 
World!', 'Hello', 0)

The first will show a message box, while the second will show nothing. You 
won't get an error message or a debugger from mypythonw.exe. It'll just 
silently do nothing.

There must be something in the configuration of pythonw.vcxproj that is 
necessary for Python embedding to work, and which makes it work in pythonw but 
fail in mypythonw. The two projects are executing the exact same C code, but 
one works and the other doesn't. What's going on here?

--
messages: 300055
nosy: rutski
priority: normal
severity: normal
status: open
title: Py_Main() is totally broken on Visual Studio 2017

___
Python tracker 
<http://bugs.python.org/issue31172>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31172] Py_Main() is totally broken on Visual Studio 2017

2017-08-10 Thread Patrick Rutkowski

Patrick Rutkowski added the comment:

Just for kicks I tried the same Py_Main() code from a Win32 console application 
(instead of from a GUI application). The C code this time was

#include 

int wmain(int argc, wchar_t** argv) {
return Py_Main(argc, argv);
}

The resulting error message when trying to run the program is now

===
> mypythoncmd.exe -c "import ctypes; ctypes.windll.user32.MessageBoxW(0, 'Hello 
> World!', 'Hello', 0)"

Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x09f0 (most recent call first):
OUTPUT ENDS HERE
===

--
assignee:  -> christian.heimes
components: +SSL
nosy: +christian.heimes

___
Python tracker 
<http://bugs.python.org/issue31172>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31172] Py_Main() is totally broken on Visual Studio 2017

2017-08-10 Thread Patrick Rutkowski

Patrick Rutkowski added the comment:

I removed my custom built Python and installed the one provided by the 
python-3.6.2-amd64.exe installer instead.

The Win32 Command Line application now works, and shows the message box. The 
Win32 GUI Application still fails to work, the output is just nothing. As 
expected, pythonw works as always, it shows the popup.

--

___
Python tracker 
<http://bugs.python.org/issue31172>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com