mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -4,6 +4,7 @@ import sys
|
||||
import traceback
|
||||
|
||||
from pydevd_constants import USE_LIB_COPY
|
||||
from pydevd_constants import IS_JYTHON
|
||||
|
||||
try:
|
||||
if USE_LIB_COPY:
|
||||
@@ -156,7 +157,7 @@ class BaseInterpreterInterface:
|
||||
if hasattr(self.interpreter, 'is_complete'):
|
||||
return not self.interpreter.is_complete(source)
|
||||
try:
|
||||
code = self.interpreter.compile(source, "<input>", "exec")
|
||||
code = self.interpreter.compile(source, '<input>', 'exec')
|
||||
except (OverflowError, SyntaxError, ValueError):
|
||||
# Case 1
|
||||
return False
|
||||
@@ -173,7 +174,7 @@ class BaseInterpreterInterface:
|
||||
else:
|
||||
self.buffer.append(code_fragment)
|
||||
|
||||
return self.needMoreForCode(code_fragment.text)
|
||||
return self.needMoreForCode(self.buffer.text)
|
||||
|
||||
def addExec(self, code_fragment):
|
||||
original_in = sys.stdin
|
||||
@@ -208,7 +209,7 @@ class BaseInterpreterInterface:
|
||||
self._input_error_printed = True
|
||||
sys.stderr.write('\nError when trying to update pydoc.help.input\n')
|
||||
sys.stderr.write('(help() may not work -- please report this as a bug in the pydev bugtracker).\n\n')
|
||||
import traceback;
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
|
||||
@@ -320,7 +321,11 @@ class BaseInterpreterInterface:
|
||||
try:
|
||||
code_fragment = CodeFragment(code, is_single_line)
|
||||
more = self.needMore(code_fragment)
|
||||
self.exec_queue.put(code_fragment)
|
||||
if not more:
|
||||
code_fragment = self.buffer
|
||||
self.buffer = None
|
||||
self.exec_queue.put(code_fragment)
|
||||
|
||||
return more
|
||||
except:
|
||||
traceback.print_exc()
|
||||
@@ -331,7 +336,11 @@ class BaseInterpreterInterface:
|
||||
|
||||
|
||||
def execMultipleLines(self, lines):
|
||||
return self.doExecCode(lines, False)
|
||||
if IS_JYTHON:
|
||||
for line in lines.split('\n'):
|
||||
self.doExecCode(line, True)
|
||||
else:
|
||||
return self.doExecCode(lines, False)
|
||||
|
||||
|
||||
def interrupt(self):
|
||||
|
||||
@@ -75,7 +75,7 @@ except ImportError:
|
||||
|
||||
|
||||
class Command:
|
||||
def __init__(self, interpreter, code_fragment, buffer):
|
||||
def __init__(self, interpreter, code_fragment):
|
||||
"""
|
||||
:type code_fragment: CodeFragment
|
||||
:type interpreter: InteractiveConsole
|
||||
@@ -83,24 +83,19 @@ class Command:
|
||||
self.interpreter = interpreter
|
||||
self.code_fragment = code_fragment
|
||||
self.more = None
|
||||
self.buffer = buffer
|
||||
|
||||
@staticmethod
|
||||
def symbol_for_fragment(code_fragment):
|
||||
if IS_JYTHON or code_fragment.is_single_line:
|
||||
if code_fragment.is_single_line:
|
||||
symbol = 'single'
|
||||
else:
|
||||
symbol = 'exec' # Jython doesn't support this
|
||||
return symbol
|
||||
|
||||
def run(self):
|
||||
if self.buffer is None:
|
||||
text = self.code_fragment.text
|
||||
symbol = self.symbol_for_fragment(self.code_fragment)
|
||||
else:
|
||||
text = self.buffer.text
|
||||
symbol = self.symbol_for_fragment(self.buffer)
|
||||
|
||||
text = self.code_fragment.text
|
||||
symbol = self.symbol_for_fragment(self.code_fragment)
|
||||
|
||||
self.more = self.interpreter.runsource(text, '<input>', symbol)
|
||||
|
||||
try:
|
||||
@@ -133,7 +128,7 @@ class InterpreterInterface(BaseInterpreterInterface):
|
||||
|
||||
|
||||
def doAddExec(self, codeFragment):
|
||||
command = Command(self.interpreter, codeFragment, self.buffer)
|
||||
command = Command(self.interpreter, codeFragment)
|
||||
command.run()
|
||||
return command.more
|
||||
|
||||
@@ -170,9 +165,6 @@ def process_exec_queue(interpreter):
|
||||
continue
|
||||
|
||||
more = interpreter.addExec(codeFragment)
|
||||
|
||||
if not more:
|
||||
interpreter.buffer = None
|
||||
except KeyboardInterrupt:
|
||||
interpreter.buffer = None
|
||||
continue
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
__author__ = 'Dmitry.Trofimov'
|
||||
|
||||
import unittest
|
||||
import os
|
||||
|
||||
test_data_path = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', '..', '..', 'python', 'testData', 'debug'))
|
||||
|
||||
class PyDevTestCase(unittest.TestCase):
|
||||
def testZipFileExits(self):
|
||||
from pydevd_file_utils import exists
|
||||
self.assertTrue(exists('../../../testData/debug/zipped_lib.zip/zipped_module.py'))
|
||||
self.assertFalse(exists('../../../testData/debug/zipped_lib.zip/zipped_module2.py'))
|
||||
self.assertFalse(exists('../../../testData/debug/zipped_lib2.zip/zipped_module.py'))
|
||||
|
||||
self.assertTrue(exists(test_data_path +'/zipped_lib.zip/zipped_module.py'))
|
||||
self.assertFalse(exists(test_data_path + '/zipped_lib.zip/zipped_module2.py'))
|
||||
self.assertFalse(exists(test_data_path + '/zipped_lib2.zip/zipped_module.py'))
|
||||
|
||||
|
||||
def testEggFileExits(self):
|
||||
from pydevd_file_utils import exists
|
||||
self.assertTrue(exists('../../../testData/debug/pycharm-debug.egg/pydev/pydevd.py'))
|
||||
self.assertFalse(exists('../../../testData/debug/pycharm-debug.egg/pydev/pydevd2.py'))
|
||||
self.assertTrue(exists(test_data_path + '/pycharm-debug.egg/pydev/pydevd.py'))
|
||||
self.assertFalse(exists(test_data_path + '/pycharm-debug.egg/pydev/pydevd2.py'))
|
||||
|
||||
Reference in New Issue
Block a user