[issue24748] Change of behavior for importlib between 3.4 and 3.5 with DLL loading

2015-07-29 Thread Etienne Fortin

New submission from Etienne Fortin:

The pywin32 package use imp.load_dynamic() to load a DLL with Windows specific 
type. On Python 3.4+ imp.load_dynamic() point to the following code which use 
the newer importlib module:

import importlib.machinery
loader = importlib.machinery.ExtensionFileLoader(name, path)
return loader.load_module()

In pywin32 a mechanism is used to be able to have part of a module globals 
defined in python (pywintypes.py), and the reminder in a DLL 
(pywintypesXX.dll). The code in pywin32 between 3.4 and 3.5 is the same.

In Python 3.4, calling imp.load_dynamic(), which point to the code above, 
inside the python part of the module definition loads the types defined in the 
DLL.

In Python 3.5, calling imp.load_dynamic(), which also points to the code above, 
inside the python part of the module definition reloads the same python module, 
not the DLL. Even though a path to a DLL is given AND when doing introspection 
of the module it clearly points to the specified DLL. 

This is a change of behavior that breaks pywin32, but possibly other modules 
that rely on this behavior.

--
components: Extension Modules, Windows
files: pywintypes.py
messages: 247573
nosy: ebfortin, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Change of behavior for importlib between 3.4 and 3.5 with DLL loading
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file40055/pywintypes.py

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



[issue24748] Change of behavior for importlib between 3.4 and 3.5 with DLL loading

2015-07-29 Thread Etienne Fortin

Etienne Fortin added the comment:

It is also possible that the root cause is related to Microsoft Windows Update 
2999226 and/or 3065987. The behavior was the same between 3.4 and 3.5 on a 
machine without these updates and is believed to have changed after the install 
of these updates.

--

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



[issue24748] Change of behavior for importlib between 3.4 and 3.5 with DLL loading

2015-07-29 Thread Etienne Fortin

Etienne Fortin added the comment:

No the behavior only changed for 3.5. 3.4 works just fine.

--

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



[issue24748] Change of behavior for importlib between 3.4 and 3.5 with DLL loading

2015-07-29 Thread Etienne Fortin

Etienne Fortin added the comment:

I suggest the test should use pywin32. The test script could be only:

import pywintypes
dir(pywintypes)

Testing for an attribute that is defined in the DLL would make it pass or fail.

--

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



[issue24748] Change of behavior for importlib between 3.4 and 3.5 with DLL loading

2015-07-29 Thread Etienne Fortin

Etienne Fortin added the comment:

At this point I can't say if it's Windows only or if it affect all platform. I 
can't even guarantee that it will appear on all Windows platform. On my 
platform (see following), it doesn't work:

Windows 7 64 bits with updates 2999226 and 3065987 installed.

I can't confirm the update are related either. I just did a quick analysis and 
between the time 3.5 was working and wasn't anymore these updates were 
installed.

I will create a quick script to reproduce the behavior.

--

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



[issue24748] Change of behavior for importlib between 3.4 and 3.5 with DLL loading

2015-07-29 Thread Etienne Fortin

Etienne Fortin added the comment:

The only dll / pyd files I have are all in pywin32. I don't have a build 
environment for extensions. Can anyone provide me with a very simple extension 
DLL with at least one exported attribute?

--

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



[issue24748] Change of behavior for importlib between 3.4 and 3.5 with DLL loading

2015-07-29 Thread Etienne Fortin

Etienne Fortin added the comment:

Is it possible that the C runtime introduced with 2999226, which I believe is 
the "universal runtime" Microsoft is trying to introduce, modified something 
that makes importlib break on 3.5???

--

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



[issue24748] Change of behavior for importlib between 3.4 and 3.5 with DLL loading

2015-07-30 Thread Etienne Fortin

Etienne Fortin added the comment:

I replaced:
import importlib.machinery
loader = importlib.machinery.ExtensionFileLoader(name, path)
return loader.load_module()

With:
import importlib.machinery
loader = importlib.machinery.ExtensionFileLoader(modname, filename)
spec = importlib.machinery.ModuleSpec(
name = modname,
loader = loader,
origin = filename,
loader_state = 1234,
is_package = False,
)
mod = loader.create_module(spec)
loader.exec_module(mod)

And it now works as advertised. Since load_module() is flagged as Deprecated, I 
believe no correction is necessary as the preffered way to load a module, with 
exec_module(), is working. 

I will do some more tests to be sure it's the case.

--

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