PY-32531 (refix PY-31650) TypeError: argument of type 'NoneType' is not iterable

Revert saving module by its name and fix name when running with Python Console
This commit is contained in:
Elizaveta Shashkova
2018-11-07 14:19:34 +03:00
parent 560a19a4f7
commit 1aec31a592
4 changed files with 8 additions and 7 deletions
@@ -156,7 +156,7 @@ def runfile(filename, args=None, wdir=None, is_module=False, global_vars=None):
__umd__.run(verbose=verbose)
if global_vars is None:
m = save_main_module(filename)
m = save_main_module(filename, 'pydev_umd')
global_vars = m.__dict__
try:
global_vars['__builtins__'] = __builtins__
@@ -13,19 +13,20 @@ import sys
from _pydev_bundle import pydev_log
def save_main_module(file):
def save_main_module(file, module_name):
# patch provided by: Scott Schlesier - when script is run, it does not
# use globals from pydevd:
# This will prevent the pydevd script from contaminating the namespace for the script to be debugged
# pretend pydevd is not the main module, and
# convince the file to be debugged that it was loaded as main
original_main = sys.modules['__main__']
sys.modules[module_name] = sys.modules['__main__']
sys.modules[module_name].__name__ = module_name
from imp import new_module
m = new_module('__main__')
sys.modules['__main__'] = m
if hasattr(original_main, '__loader__'):
m.__loader__ = getattr(original_main, '__loader__')
if hasattr(sys.modules[module_name], '__loader__'):
m.__loader__ = getattr(sys.modules[module_name], '__loader__')
m.__file__ = file
return m
+1 -1
View File
@@ -72,7 +72,7 @@ class InterpreterInterface(BaseInterpreterInterface):
self._input_error_printed = False
def save_main(self):
m = save_main_module('<input>')
m = save_main_module('<input>', 'pydevconsole')
self.namespace = m.__dict__
try:
self.namespace['__builtins__'] = __builtins__
+1 -1
View File
@@ -1013,7 +1013,7 @@ class PyDB:
file = new_target
if globals is None:
m = save_main_module(file)
m = save_main_module(file, 'pydevd')
globals = m.__dict__
try:
globals['__builtins__'] = __builtins__