eric7/DebugClients/Python/ModuleLoader.py

Thu, 30 Dec 2021 11:17:58 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 30 Dec 2021 11:17:58 +0100
branch
eric7
changeset 8881
54e42bc2437a
parent 8831
9d676f442b1b
child 8940
e91951ff3bbd
permissions
-rw-r--r--

Updated copyright for 2022.

7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8831
diff changeset
3 # Copyright (c) 2020 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing an import hook patching modules to support debugging.
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import sys
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import importlib
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
7407
a0b6acee2c20 Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7404
diff changeset
13 from QProcessExtension import patchQProcess
7424
9bb7d8b0f966 Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7409
diff changeset
14 from SubprocessExtension import patchSubprocess
7563
b0d6b63f2843 Implemented multi process debugging support for the 'multiprocessing' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7424
diff changeset
15 from MultiprocessingExtension import patchMultiprocessing
7407
a0b6acee2c20 Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7404
diff changeset
16
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
8207
d359172d11be Applied some more code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
18 class ModuleLoader:
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing an import hook patching modules to support debugging.
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 def __init__(self, debugClient):
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Constructor
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param debugClient reference to the debug client object
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @type DebugClient
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 self.__dbgClient = debugClient
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 self.__enableImportHooks = True
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 # reset already imported thread module to apply hooks at next import
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 for moduleName in ("thread", "_thread", "threading"):
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 if moduleName in sys.modules:
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 del sys.modules[moduleName]
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.__modulesToPatch = (
8831
9d676f442b1b Removed a left over from Python2 times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8314
diff changeset
39 '_thread', 'threading',
7407
a0b6acee2c20 Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7404
diff changeset
40 'greenlet',
7424
9bb7d8b0f966 Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7409
diff changeset
41 'subprocess',
7563
b0d6b63f2843 Implemented multi process debugging support for the 'multiprocessing' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7424
diff changeset
42 'multiprocessing',
7646
39e3db2b4936 Merged with default to track recent development.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7563
diff changeset
43 'PyQt5.QtCore',
7911
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7894
diff changeset
44 'PyQt6.QtCore',
7646
39e3db2b4936 Merged with default to track recent development.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7563
diff changeset
45 'PySide2.QtCore',
7911
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7894
diff changeset
46 'PySide6.QtCore',
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 )
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 sys.meta_path.insert(0, self)
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 def __loadModule(self, fullname):
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
7407
a0b6acee2c20 Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7404
diff changeset
53 Private method to load a module.
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 @param fullname name of the module to be loaded
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @type str
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 @return reference to the loaded module
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @rtype module
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 module = importlib.import_module(fullname)
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 sys.modules[fullname] = module
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 ## Add hook for _thread.start_new_thread
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 if (
8831
9d676f442b1b Removed a left over from Python2 times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8314
diff changeset
65 fullname == '_thread' and
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
66 not hasattr(module, 'eric7_patched')
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 ):
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
68 module.eric7_patched = True
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.__dbgClient.patchPyThread(module)
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 ## Add hook for threading.run()
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 elif (
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 fullname == "threading" and
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
74 not hasattr(module, 'eric7_patched')
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 ):
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
76 module.eric7_patched = True
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.__dbgClient.patchPyThreading(module)
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 ## greenlet support
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 elif (
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 fullname == 'greenlet' and
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
82 not hasattr(module, 'eric7_patched')
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 ):
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 if self.__dbgClient.patchGreenlet(module):
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
85 module.eric7_patched = True
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
7424
9bb7d8b0f966 Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7409
diff changeset
87 ## Add hook for subprocess.Popen()
9bb7d8b0f966 Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7409
diff changeset
88 elif (
9bb7d8b0f966 Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7409
diff changeset
89 fullname == 'subprocess' and
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
90 not hasattr(module, 'eric7_patched')
7424
9bb7d8b0f966 Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7409
diff changeset
91 ):
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
92 module.eric7_patched = True
7424
9bb7d8b0f966 Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7409
diff changeset
93 patchSubprocess(module, self.__dbgClient)
7563
b0d6b63f2843 Implemented multi process debugging support for the 'multiprocessing' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7424
diff changeset
94
b0d6b63f2843 Implemented multi process debugging support for the 'multiprocessing' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7424
diff changeset
95 ## Add hook for multiprocessing.Process
b0d6b63f2843 Implemented multi process debugging support for the 'multiprocessing' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7424
diff changeset
96 elif (
b0d6b63f2843 Implemented multi process debugging support for the 'multiprocessing' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7424
diff changeset
97 fullname == 'multiprocessing' and
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
98 not hasattr(module, 'eric7_patched')
7563
b0d6b63f2843 Implemented multi process debugging support for the 'multiprocessing' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7424
diff changeset
99 ):
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
100 module.eric7_patched = True
7563
b0d6b63f2843 Implemented multi process debugging support for the 'multiprocessing' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7424
diff changeset
101 patchMultiprocessing(module, self.__dbgClient)
b0d6b63f2843 Implemented multi process debugging support for the 'multiprocessing' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7424
diff changeset
102
7407
a0b6acee2c20 Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7404
diff changeset
103 ## Add hook for *.QThread and *.QProcess
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 elif (
7911
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7894
diff changeset
105 fullname in ('PyQt5.QtCore', 'PyQt6.QtCore',
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7894
diff changeset
106 'PySide2.QtCore', 'PySide6.QtCore') and
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
107 not hasattr(module, 'eric7_patched')
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 ):
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
109 module.eric7_patched = True
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.__dbgClient.patchQThread(module)
7409
1413bfe73d41 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7408
diff changeset
111 patchQProcess(module, self.__dbgClient)
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.__enableImportHooks = True
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 return module
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115
7894
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
116 def find_spec(self, fullname, path, target=None):
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
117 """
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
118 Public method returning the module spec.
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
119
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
120 @param fullname name of the module to be loaded
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
121 @type str
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
122 @param path path to resolve the module name
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
123 @type str
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
124 @param target module object to use for a more educated guess
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
125 about what spec to return
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
126 @type module
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
127 @return module spec object pointing to the module loader
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
128 @rtype ModuleSpec
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
129 """
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
130 if fullname in sys.modules or not self.__dbgClient.debugging:
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 return None
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
7894
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
133 if (
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
134 fullname in self.__modulesToPatch and
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
135 self.__enableImportHooks
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
136 ):
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
137 # Disable hook to be able to import original module
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
138 self.__enableImportHooks = False
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
139 return importlib.machinery.ModuleSpec(fullname, self)
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140
7894
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
141 return None
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142
7894
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
143 def create_module(self, spec):
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
144 """
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
145 Public method to create a module based on the passed in spec.
7404
663f1c3d6f53 Placed the module loader and patching logic into a separate module of the debug client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
7894
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
147 @param spec module spec object for loading the module
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
148 @type ModuleSpec
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
149 @return created and patched module
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
150 @rtype module
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
151 """
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
152 return self.__loadModule(spec.name)
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
153
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
154 def exec_module(self, module):
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
155 """
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
156 Public method to execute the created module.
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
157
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
158 @param module module to be executed
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
159 @type module
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
160 """
4370a8b30648 Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7887
diff changeset
161 pass

eric ide

mercurial