mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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:
@@ -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
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -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__
|
||||
|
||||
Reference in New Issue
Block a user