{
    "file_diffs": [
        {
            "old_file_content": "import sys\nimport os\nimport code\nimport keyword\nimport itertools\nimport unicodedata\nimport weakref\nfrom functools import reduce\nfrom unittest.mock import patch\n\nfrom typing import Optional, List, TYPE_CHECKING\n\nfrom AnyQt.QtWidgets import (\n    QPlainTextEdit, QListView, QSizePolicy, QMenu, QSplitter, QLineEdit,\n    QAction, QToolButton, QFileDialog, QStyledItemDelegate,\n    QStyleOptionViewItem, QPlainTextDocumentLayout\n)\nfrom AnyQt.QtGui import (\n    QColor, QBrush, QPalette, QFont, QTextDocument,\n    QSyntaxHighlighter, QTextCharFormat, QTextCursor, QKeySequence,\n)\nfrom AnyQt.QtCore import Qt, QRegExp, QByteArray, QItemSelectionModel, QSize\n\nfrom Orange.data import Table\nfrom Orange.base import Learner, Model\nfrom Orange.util import interleave\nfrom Orange.widgets import gui\nfrom Orange.widgets.utils import itemmodels\nfrom Orange.widgets.settings import Setting\nfrom Orange.widgets.utils.widgetpreview import WidgetPreview\nfrom Orange.widgets.widget import OWWidget, Input, Output\n\nif TYPE_CHECKING:\n    from typing_extensions import TypedDict\n\n__all__ = [\"OWPythonScript\"]\n\n\ndef text_format(foreground=Qt.black, weight=QFont.Normal):\n    fmt = QTextCharFormat()\n    fmt.setForeground(QBrush(foreground))\n    fmt.setFontWeight(weight)\n    return fmt\n\n\ndef read_file_content(filename, limit=None):\n    try:\n        with open(filename, encoding=\"utf-8\", errors='strict') as f:\n            text = f.read(limit)\n            return text\n    except (OSError, UnicodeDecodeError):\n        return None\n\n\nclass PythonSyntaxHighlighter(QSyntaxHighlighter):\n    def __init__(self, parent=None):\n\n        self.keywordFormat = text_format(Qt.blue, QFont.Bold)\n        self.stringFormat = text_format(Qt.darkGreen)\n        self.defFormat = text_format(Qt.black, QFont.Bold)\n        self.commentFormat = text_format(Qt.lightGray)\n        self.decoratorFormat = text_format(Qt.darkGray)\n\n        self.keywords = list(keyword.kwlist)\n\n        self.rules = [(QRegExp(r\"\\b%s\\b\" % kwd), self.keywordFormat)\n                      for kwd in self.keywords] + \\\n                     [(QRegExp(r\"\\bdef\\s+([A-Za-z_]+[A-Za-z0-9_]+)\\s*\\(\"),\n                       self.defFormat),\n                      (QRegExp(r\"\\bclass\\s+([A-Za-z_]+[A-Za-z0-9_]+)\\s*\\(\"),\n                       self.defFormat),\n                      (QRegExp(r\"'.*'\"), self.stringFormat),\n                      (QRegExp(r'\".*\"'), self.stringFormat),\n                      (QRegExp(r\"#.*\"), self.commentFormat),\n                      (QRegExp(r\"@[A-Za-z_]+[A-Za-z0-9_]+\"),\n                       self.decoratorFormat)]\n\n        self.multilineStart = QRegExp(r\"(''')|\" + r'(\"\"\")')\n        self.multilineEnd = QRegExp(r\"(''')|\" + r'(\"\"\")')\n\n        super().__init__(parent)\n\n    def highlightBlock(self, text):\n        for pattern, fmt in self.rules:\n            exp = QRegExp(pattern)\n            index = exp.indexIn(text)\n            while index >= 0:\n                length = exp.matchedLength()\n                if exp.captureCount() > 0:\n                    self.setFormat(exp.pos(1), len(str(exp.cap(1))), fmt)\n                else:\n                    self.setFormat(exp.pos(0), len(str(exp.cap(0))), fmt)\n                index = exp.indexIn(text, index + length)\n\n        # Multi line strings\n        start = self.multilineStart\n        end = self.multilineEnd\n\n        self.setCurrentBlockState(0)\n        startIndex, skip = 0, 0\n        if self.previousBlockState() != 1:\n            startIndex, skip = start.indexIn(text), 3\n        while startIndex >= 0:\n            endIndex = end.indexIn(text, startIndex + skip)\n            if endIndex == -1:\n                self.setCurrentBlockState(1)\n                commentLen = len(text) - startIndex\n            else:\n                commentLen = endIndex - startIndex + 3\n            self.setFormat(startIndex, commentLen, self.stringFormat)\n            startIndex, skip = (start.indexIn(text,\n                                              startIndex + commentLen + 3),\n                                3)\n\n\nclass PythonScriptEditor(QPlainTextEdit):\n    INDENT = 4\n\n    def __init__(self, widget):\n        super().__init__()\n        self.widget = widget\n\n    def lastLine(self):\n        text = str(self.toPlainText())\n        pos = self.textCursor().position()\n        index = text.rfind(\"\\n\", 0, pos)\n        text = text[index: pos].lstrip(\"\\n\")\n        return text\n\n    def keyPressEvent(self, event):\n        if event.key() == Qt.Key_Return:\n            if event.modifiers() & (\n                    Qt.ShiftModifier | Qt.ControlModifier | Qt.MetaModifier):\n                self.widget.commit()\n                return\n            text = self.lastLine()\n            indent = len(text) - len(text.lstrip())\n            if text.strip() == \"pass\" or text.strip().startswith(\"return \"):\n                indent = max(0, indent - self.INDENT)\n            elif text.strip().endswith(\":\"):\n                indent += self.INDENT\n            super().keyPressEvent(event)\n            self.insertPlainText(\" \" * indent)\n        elif event.key() == Qt.Key_Tab:\n            self.insertPlainText(\" \" * self.INDENT)\n        elif event.key() == Qt.Key_Backspace:\n            text = self.lastLine()\n            if text and not text.strip():\n                cursor = self.textCursor()\n                for _ in range(min(self.INDENT, len(text))):\n                    cursor.deletePreviousChar()\n            else:\n                super().keyPressEvent(event)\n\n        else:\n            super().keyPressEvent(event)\n\n    def insertFromMimeData(self, source):\n        \"\"\"\n        Reimplemented from QPlainTextEdit.insertFromMimeData.\n        \"\"\"\n        urls = source.urls()\n        if urls:\n            self.pasteFile(urls[0])\n        else:\n            super().insertFromMimeData(source)\n\n    def pasteFile(self, url):\n        new = read_file_content(url.toLocalFile())\n        if new:\n            # inserting text like this allows undo\n            cursor = QTextCursor(self.document())\n            cursor.select(QTextCursor.Document)\n            cursor.insertText(new)\n\n\nclass PythonConsole(QPlainTextEdit, code.InteractiveConsole):\n    # `locals` is reasonably used as argument name\n    # pylint: disable=redefined-builtin\n    def __init__(self, locals=None, parent=None):\n        QPlainTextEdit.__init__(self, parent)\n        code.InteractiveConsole.__init__(self, locals)\n        self.newPromptPos = 0\n        self.history, self.historyInd = [\"\"], 0\n        self.loop = self.interact()\n        next(self.loop)\n\n    def setLocals(self, locals):\n        self.locals = locals\n\n    def updateLocals(self, locals):\n        self.locals.update(locals)\n\n    def interact(self, banner=None, _=None):\n        try:\n            sys.ps1\n        except AttributeError:\n            sys.ps1 = \">>> \"\n        try:\n            sys.ps2\n        except AttributeError:\n            sys.ps2 = \"... \"\n        cprt = ('Type \"help\", \"copyright\", \"credits\" or \"license\" '\n                'for more information.')\n        if banner is None:\n            self.write(\"Python %s on %s\\n%s\\n(%s)\\n\" %\n                       (sys.version, sys.platform, cprt,\n                        self.__class__.__name__))\n        else:\n            self.write(\"%s\\n\" % str(banner))\n        more = 0\n        while 1:\n            try:\n                if more:\n                    prompt = sys.ps2\n                else:\n                    prompt = sys.ps1\n                self.new_prompt(prompt)\n                yield\n                try:\n                    line = self.raw_input(prompt)\n                except EOFError:\n                    self.write(\"\\n\")\n                    break\n                else:\n                    more = self.push(line)\n            except KeyboardInterrupt:\n                self.write(\"\\nKeyboardInterrupt\\n\")\n                self.resetbuffer()\n                more = 0\n\n    def raw_input(self, prompt=\"\"):\n        input_str = str(self.document().lastBlock().previous().text())\n        return input_str[len(prompt):]\n\n    def new_prompt(self, prompt):\n        self.write(prompt)\n        self.newPromptPos = self.textCursor().position()\n        self.repaint()\n\n    def write(self, data):\n        cursor = QTextCursor(self.document())\n        cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor)\n        cursor.insertText(data)\n        self.setTextCursor(cursor)\n        self.ensureCursorVisible()\n\n    def writelines(self, lines):\n        for line in lines:\n            self.write(line)\n\n    def flush(self):\n        pass\n\n    def push(self, line):\n        if self.history[0] != line:\n            self.history.insert(0, line)\n        self.historyInd = 0\n\n        # prevent console errors to trigger error reporting & patch stdout, stderr\n        with patch('sys.excepthook', sys.__excepthook__),\\\n             patch('sys.stdout', self),\\\n             patch('sys.stderr', self):\n            return code.InteractiveConsole.push(self, line)\n\n    def setLine(self, line):\n        cursor = QTextCursor(self.document())\n        cursor.movePosition(QTextCursor.End)\n        cursor.setPosition(self.newPromptPos, QTextCursor.KeepAnchor)\n        cursor.removeSelectedText()\n        cursor.insertText(line)\n        self.setTextCursor(cursor)\n\n    def keyPressEvent(self, event):\n        if event.key() == Qt.Key_Return:\n            self.write(\"\\n\")\n            next(self.loop)\n        elif event.key() == Qt.Key_Up:\n            self.historyUp()\n        elif event.key() == Qt.Key_Down:\n            self.historyDown()\n        elif event.key() == Qt.Key_Tab:\n            self.complete()\n        elif event.key() in [Qt.Key_Left, Qt.Key_Backspace]:\n            if self.textCursor().position() > self.newPromptPos:\n                QPlainTextEdit.keyPressEvent(self, event)\n        else:\n            QPlainTextEdit.keyPressEvent(self, event)\n\n    def historyUp(self):\n        self.setLine(self.history[self.historyInd])\n        self.historyInd = min(self.historyInd + 1, len(self.history) - 1)\n\n    def historyDown(self):\n        self.setLine(self.history[self.historyInd])\n        self.historyInd = max(self.historyInd - 1, 0)\n\n    def complete(self):\n        pass\n\n    def _moveCursorToInputLine(self):\n        \"\"\"\n        Move the cursor to the input line if not already there. If the cursor\n        if already in the input line (at position greater or equal to\n        `newPromptPos`) it is left unchanged, otherwise it is moved at the\n        end.\n\n        \"\"\"\n        cursor = self.textCursor()\n        pos = cursor.position()\n        if pos < self.newPromptPos:\n            cursor.movePosition(QTextCursor.End)\n            self.setTextCursor(cursor)\n\n    def pasteCode(self, source):\n        \"\"\"\n        Paste source code into the console.\n        \"\"\"\n        self._moveCursorToInputLine()\n\n        for line in interleave(source.splitlines(), itertools.repeat(\"\\n\")):\n            if line != \"\\n\":\n                self.insertPlainText(line)\n            else:\n                self.write(\"\\n\")\n                next(self.loop)\n\n    def insertFromMimeData(self, source):\n        \"\"\"\n        Reimplemented from QPlainTextEdit.insertFromMimeData.\n        \"\"\"\n        if source.hasText():\n            self.pasteCode(str(source.text()))\n            return\n\n\nclass Script:\n    Modified = 1\n    MissingFromFilesystem = 2\n\n    def __init__(self, name, script, flags=0, filename=None):\n        self.name = name\n        self.script = script\n        self.flags = flags\n        self.filename = filename\n\n    def asdict(self) -> '_ScriptData':\n        return dict(name=self.name, script=self.script, filename=self.filename)\n\n    @classmethod\n    def fromdict(cls, state: '_ScriptData') -> 'Script':\n        return Script(state[\"name\"], state[\"script\"], filename=state[\"filename\"])\n\n\nclass ScriptItemDelegate(QStyledItemDelegate):\n    # pylint: disable=no-self-use\n    def displayText(self, script, _locale):\n        if script.flags & Script.Modified:\n            return \"*\" + script.name\n        else:\n            return script.name\n\n    def paint(self, painter, option, index):\n        script = index.data(Qt.DisplayRole)\n\n        if script.flags & Script.Modified:\n            option = QStyleOptionViewItem(option)\n            option.palette.setColor(QPalette.Text, QColor(Qt.red))\n            option.palette.setColor(QPalette.Highlight, QColor(Qt.darkRed))\n        super().paint(painter, option, index)\n\n    def createEditor(self, parent, _option, _index):\n        return QLineEdit(parent)\n\n    def setEditorData(self, editor, index):\n        script = index.data(Qt.DisplayRole)\n        editor.setText(script.name)\n\n    def setModelData(self, editor, model, index):\n        model[index.row()].name = str(editor.text())\n\n\ndef select_row(view, row):\n    \"\"\"\n    Select a `row` in an item view\n    \"\"\"\n    selmodel = view.selectionModel()\n    selmodel.select(view.model().index(row, 0),\n                    QItemSelectionModel.ClearAndSelect)\n\n\nif TYPE_CHECKING:\n    # pylint: disable=used-before-assignment\n    _ScriptData = TypedDict(\"_ScriptData\", {\n        \"name\": str, \"script\": str, \"filename\": Optional[str]\n    })\n\n\nclass OWPythonScript(OWWidget):\n    name = \"Python Script\"\n    description = \"Write a Python script and run it on input data or models.\"\n    icon = \"icons/PythonScript.svg\"\n    priority = 3150\n    keywords = [\"file\", \"program\"]\n\n    class Inputs:\n        data = Input(\"Data\", Table, replaces=[\"in_data\"],\n                     default=True, multiple=True)\n        learner = Input(\"Learner\", Learner, replaces=[\"in_learner\"],\n                        default=True, multiple=True)\n        classifier = Input(\"Classifier\", Model, replaces=[\"in_classifier\"],\n                           default=True, multiple=True)\n        object = Input(\"Object\", object, replaces=[\"in_object\"],\n                       default=False, multiple=True)\n\n    class Outputs:\n        data = Output(\"Data\", Table, replaces=[\"out_data\"])\n        learner = Output(\"Learner\", Learner, replaces=[\"out_learner\"])\n        classifier = Output(\"Classifier\", Model, replaces=[\"out_classifier\"])\n        object = Output(\"Object\", object, replaces=[\"out_object\"])\n\n    signal_names = (\"data\", \"learner\", \"classifier\", \"object\")\n\n    settings_version = 2\n    scriptLibrary: 'List[_ScriptData]' = Setting([{\n        \"name\": \"Hello world\",\n        \"script\": \"print('Hello world')\\n\",\n        \"filename\": None\n    }])\n    currentScriptIndex = Setting(0)\n    scriptText: Optional[str] = Setting(None, schema_only=True)\n    splitterState: Optional[bytes] = Setting(None)\n\n    # Widgets in the same schema share namespace through a dictionary whose\n    # key is self.signalManager. ales-erjavec expressed concern (and I fully\n    # agree!) about widget being aware of the outside world. I am leaving this\n    # anyway. If this causes any problems in the future, replace this with\n    # shared_namespaces = {} and thus use a common namespace for all instances\n    # of # PythonScript even if they are in different schemata.\n    shared_namespaces = weakref.WeakKeyDictionary()\n\n    class Error(OWWidget.Error):\n        pass\n\n    def __init__(self):\n        super().__init__()\n        self.libraryListSource = []\n\n        for name in self.signal_names:\n            setattr(self, name, {})\n\n        self._cachedDocuments = {}\n\n        self.infoBox = gui.vBox(self.controlArea, 'Info')\n        gui.label(\n            self.infoBox, self,\n            \"<p>Execute python script.</p><p>Input variables:<ul><li> \" +\n            \"<li>\".join(map(\"in_{0}, in_{0}s\".format, self.signal_names)) +\n            \"</ul></p><p>Output variables:<ul><li>\" +\n            \"<li>\".join(map(\"out_{0}\".format, self.signal_names)) +\n            \"</ul></p>\"\n        )\n\n        self.libraryList = itemmodels.PyListModel(\n            [], self,\n            flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)\n\n        self.libraryList.wrap(self.libraryListSource)\n\n        self.controlBox = gui.vBox(self.controlArea, 'Library')\n        self.controlBox.layout().setSpacing(1)\n\n        self.libraryView = QListView(\n            editTriggers=QListView.DoubleClicked |\n            QListView.EditKeyPressed,\n            sizePolicy=QSizePolicy(QSizePolicy.Ignored,\n                                   QSizePolicy.Preferred)\n        )\n        self.libraryView.setItemDelegate(ScriptItemDelegate(self))\n        self.libraryView.setModel(self.libraryList)\n\n        self.libraryView.selectionModel().selectionChanged.connect(\n            self.onSelectedScriptChanged\n        )\n        self.controlBox.layout().addWidget(self.libraryView)\n\n        w = itemmodels.ModelActionsWidget()\n\n        self.addNewScriptAction = action = QAction(\"+\", self)\n        action.setToolTip(\"Add a new script to the library\")\n        action.triggered.connect(self.onAddScript)\n        w.addAction(action)\n\n        action = QAction(unicodedata.lookup(\"MINUS SIGN\"), self)\n        action.setToolTip(\"Remove script from library\")\n        action.triggered.connect(self.onRemoveScript)\n        w.addAction(action)\n\n        action = QAction(\"Update\", self)\n        action.setToolTip(\"Save changes in the editor to library\")\n        action.setShortcut(QKeySequence(QKeySequence.Save))\n        action.triggered.connect(self.commitChangesToLibrary)\n        w.addAction(action)\n\n        action = QAction(\"More\", self, toolTip=\"More actions\")\n\n        new_from_file = QAction(\"Import Script from File\", self)\n        save_to_file = QAction(\"Save Selected Script to File\", self)\n        restore_saved = QAction(\"Undo Changes to Selected Script\", self)\n        save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))\n\n        new_from_file.triggered.connect(self.onAddScriptFromFile)\n        save_to_file.triggered.connect(self.saveScript)\n        restore_saved.triggered.connect(self.restoreSaved)\n\n        menu = QMenu(w)\n        menu.addAction(new_from_file)\n        menu.addAction(save_to_file)\n        menu.addAction(restore_saved)\n        action.setMenu(menu)\n        button = w.addAction(action)\n        button.setPopupMode(QToolButton.InstantPopup)\n\n        w.layout().setSpacing(1)\n\n        self.controlBox.layout().addWidget(w)\n\n        self.execute_button = gui.button(self.controlArea, self, 'Run', callback=self.commit)\n\n        run = QAction(\"Run script\", self, triggered=self.commit,\n                      shortcut=QKeySequence(Qt.ControlModifier | Qt.Key_R))\n        self.addAction(run)\n\n        self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)\n        self.mainArea.layout().addWidget(self.splitCanvas)\n\n        self.defaultFont = defaultFont = \\\n            \"Monaco\" if sys.platform == \"darwin\" else \"Courier\"\n\n        self.textBox = gui.vBox(self, 'Python Script')\n        self.splitCanvas.addWidget(self.textBox)\n        self.text = PythonScriptEditor(self)\n        self.textBox.layout().addWidget(self.text)\n\n        self.textBox.setAlignment(Qt.AlignVCenter)\n        self.text.setTabStopWidth(4)\n\n        self.text.modificationChanged[bool].connect(self.onModificationChanged)\n\n        self.saveAction = action = QAction(\"&Save\", self.text)\n        action.setToolTip(\"Save script to file\")\n        action.setShortcut(QKeySequence(QKeySequence.Save))\n        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)\n        action.triggered.connect(self.saveScript)\n\n        self.consoleBox = gui.vBox(self, 'Console')\n        self.splitCanvas.addWidget(self.consoleBox)\n        self.console = PythonConsole({}, self)\n        self.consoleBox.layout().addWidget(self.console)\n        self.console.document().setDefaultFont(QFont(defaultFont))\n        self.consoleBox.setAlignment(Qt.AlignBottom)\n        self.console.setTabStopWidth(4)\n        self.splitCanvas.setSizes([2, 1])\n        self.setAcceptDrops(True)\n        self.controlArea.layout().addStretch(10)\n\n        self._restoreState()\n        self.settingsAboutToBePacked.connect(self._saveState)\n\n    def sizeHint(self) -> QSize:\n        return super().sizeHint().expandedTo(QSize(800, 600))\n\n    def _restoreState(self):\n        self.libraryListSource = [Script.fromdict(s) for s in self.scriptLibrary]\n        self.libraryList.wrap(self.libraryListSource)\n        select_row(self.libraryView, self.currentScriptIndex)\n\n        if self.scriptText is not None:\n            current = self.text.toPlainText()\n            # do not mark scripts as modified\n            if self.scriptText != current:\n                self.text.document().setPlainText(self.scriptText)\n\n        if self.splitterState is not None:\n            self.splitCanvas.restoreState(QByteArray(self.splitterState))\n\n    def _saveState(self):\n        self.scriptLibrary = [s.asdict() for s in self.libraryListSource]\n        self.scriptText = self.text.toPlainText()\n        self.splitterState = bytes(self.splitCanvas.saveState())\n\n    def handle_input(self, obj, sig_id, signal):\n        sig_id = sig_id[0]\n        dic = getattr(self, signal)\n        if obj is None:\n            if sig_id in dic.keys():\n                del dic[sig_id]\n        else:\n            dic[sig_id] = obj\n\n    @Inputs.data\n    def set_data(self, data, sig_id):\n        self.handle_input(data, sig_id, \"data\")\n\n    @Inputs.learner\n    def set_learner(self, data, sig_id):\n        self.handle_input(data, sig_id, \"learner\")\n\n    @Inputs.classifier\n    def set_classifier(self, data, sig_id):\n        self.handle_input(data, sig_id, \"classifier\")\n\n    @Inputs.object\n    def set_object(self, data, sig_id):\n        self.handle_input(data, sig_id, \"object\")\n\n    def handleNewSignals(self):\n        self.commit()\n\n    def selectedScriptIndex(self):\n        rows = self.libraryView.selectionModel().selectedRows()\n        if rows:\n            return [i.row() for i in rows][0]\n        else:\n            return None\n\n    def setSelectedScript(self, index):\n        select_row(self.libraryView, index)\n\n    def onAddScript(self, *_):\n        self.libraryList.append(Script(\"New script\", self.text.toPlainText(), 0))\n        self.setSelectedScript(len(self.libraryList) - 1)\n\n    def onAddScriptFromFile(self, *_):\n        filename, _ = QFileDialog.getOpenFileName(\n            self, 'Open Python Script',\n            os.path.expanduser(\"~/\"),\n            'Python files (*.py)\\nAll files(*.*)'\n        )\n        if filename:\n            name = os.path.basename(filename)\n            # TODO: use `tokenize.detect_encoding`\n            with open(filename, encoding=\"utf-8\") as f:\n                contents = f.read()\n            self.libraryList.append(Script(name, contents, 0, filename))\n            self.setSelectedScript(len(self.libraryList) - 1)\n\n    def onRemoveScript(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            del self.libraryList[index]\n            select_row(self.libraryView, max(index - 1, 0))\n\n    def onSaveScriptToFile(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.saveScript()\n\n    def onSelectedScriptChanged(self, selected, _deselected):\n        index = [i.row() for i in selected.indexes()]\n        if index:\n            current = index[0]\n            if current >= len(self.libraryList):\n                self.addNewScriptAction.trigger()\n                return\n\n            self.text.setDocument(self.documentForScript(current))\n            self.currentScriptIndex = current\n\n    def documentForScript(self, script=0):\n        if not isinstance(script, Script):\n            script = self.libraryList[script]\n        if script not in self._cachedDocuments:\n            doc = QTextDocument(self)\n            doc.setDocumentLayout(QPlainTextDocumentLayout(doc))\n            doc.setPlainText(script.script)\n            doc.setDefaultFont(QFont(self.defaultFont))\n            doc.highlighter = PythonSyntaxHighlighter(doc)\n            doc.modificationChanged[bool].connect(self.onModificationChanged)\n            doc.setModified(False)\n            self._cachedDocuments[script] = doc\n        return self._cachedDocuments[script]\n\n    def commitChangesToLibrary(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.libraryList[index].script = self.text.toPlainText()\n            self.text.document().setModified(False)\n            self.libraryList.emitDataChanged(index)\n\n    def onModificationChanged(self, modified):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.libraryList[index].flags = Script.Modified if modified else 0\n            self.libraryList.emitDataChanged(index)\n\n    def restoreSaved(self):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.text.document().setPlainText(self.libraryList[index].script)\n            self.text.document().setModified(False)\n\n    def saveScript(self):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            script = self.libraryList[index]\n            filename = script.filename\n        else:\n            filename = os.path.expanduser(\"~/\")\n\n        filename, _ = QFileDialog.getSaveFileName(\n            self, 'Save Python Script',\n            filename,\n            'Python files (*.py)\\nAll files(*.*)'\n        )\n\n        if filename:\n            fn = \"\"\n            head, tail = os.path.splitext(filename)\n            if not tail:\n                fn = head + \".py\"\n            else:\n                fn = filename\n\n            f = open(fn, 'w')\n            f.write(self.text.toPlainText())\n            f.close()\n\n    def initial_locals_state(self):\n        d = self.shared_namespaces.setdefault(self.signalManager, {}).copy()\n        for name in self.signal_names:\n            value = getattr(self, name)\n            all_values = list(value.values())\n            one_value = all_values[0] if len(all_values) == 1 else None\n            d[\"in_\" + name + \"s\"] = all_values\n            d[\"in_\" + name] = one_value\n        return d\n\n    def update_namespace(self, namespace):\n        not_saved = reduce(set.union,\n                           ({f\"in_{name}s\", f\"in_{name}\", f\"out_{name}\"}\n                            for name in self.signal_names))\n        self.shared_namespaces.setdefault(self.signalManager, {}).update(\n            {name: value for name, value in namespace.items()\n             if name not in not_saved})\n\n    def commit(self):\n        self.Error.clear()\n        lcls = self.initial_locals_state()\n        lcls[\"_script\"] = str(self.text.toPlainText())\n        self.console.updateLocals(lcls)\n        self.console.write(\"\\nRunning script:\\n\")\n        self.console.push(\"exec(_script)\")\n        self.console.new_prompt(sys.ps1)\n        self.update_namespace(self.console.locals)\n        for signal in self.signal_names:\n            out_var = self.console.locals.get(\"out_\" + signal)\n            signal_type = getattr(self.Outputs, signal).type\n            if not isinstance(out_var, signal_type) and out_var is not None:\n                self.Error.add_message(signal,\n                                       \"'{}' has to be an instance of '{}'.\".\n                                       format(signal, signal_type.__name__))\n                getattr(self.Error, signal)()\n                out_var = None\n            getattr(self.Outputs, signal).send(out_var)\n\n    def dragEnterEvent(self, event):  # pylint: disable=no-self-use\n        urls = event.mimeData().urls()\n        if urls:\n            # try reading the file as text\n            c = read_file_content(urls[0].toLocalFile(), limit=1000)\n            if c is not None:\n                event.acceptProposedAction()\n\n    def dropEvent(self, event):\n        \"\"\"Handle file drops\"\"\"\n        urls = event.mimeData().urls()\n        if urls:\n            self.text.pasteFile(urls[0])\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if version is not None and version < 2:\n            scripts = settings.pop(\"libraryListSource\")  # type: List[Script]\n            library = [dict(name=s.name, script=s.script, filename=s.filename)\n                       for s in scripts]  # type: List[_ScriptData]\n            settings[\"scriptLibrary\"] = library\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    WidgetPreview(OWPythonScript).run()\n",
            "new_file_content": "import sys\nimport os\nimport code\nimport keyword\nimport itertools\nimport unicodedata\nimport weakref\nfrom functools import reduce\nfrom unittest.mock import patch\n\nfrom typing import Optional, List, TYPE_CHECKING\n\nfrom AnyQt.QtWidgets import (\n    QPlainTextEdit, QListView, QSizePolicy, QMenu, QSplitter, QLineEdit,\n    QAction, QToolButton, QFileDialog, QStyledItemDelegate,\n    QStyleOptionViewItem, QPlainTextDocumentLayout\n)\nfrom AnyQt.QtGui import (\n    QColor, QBrush, QPalette, QFont, QTextDocument,\n    QSyntaxHighlighter, QTextCharFormat, QTextCursor, QKeySequence,\n)\nfrom AnyQt.QtCore import Qt, QRegExp, QByteArray, QItemSelectionModel, QSize\n\nfrom Orange.data import Table\nfrom Orange.base import Learner, Model\nfrom Orange.util import interleave\nfrom Orange.widgets import gui\nfrom Orange.widgets.utils import itemmodels\nfrom Orange.widgets.settings import Setting\nfrom Orange.widgets.utils.widgetpreview import WidgetPreview\nfrom Orange.widgets.widget import OWWidget, Input, Output\n\nif TYPE_CHECKING:\n    from typing_extensions import TypedDict\n\n__all__ = [\"OWPythonScript\"]\n\n\ndef text_format(foreground=Qt.black, weight=QFont.Normal):\n    fmt = QTextCharFormat()\n    fmt.setForeground(QBrush(foreground))\n    fmt.setFontWeight(weight)\n    return fmt\n\n\ndef read_file_content(filename, limit=None):\n    try:\n        with open(filename, encoding=\"utf-8\", errors='strict') as f:\n            text = f.read(limit)\n            return text\n    except (OSError, UnicodeDecodeError):\n        return None\n\n\nclass PythonSyntaxHighlighter(QSyntaxHighlighter):\n    def __init__(self, parent=None):\n\n        self.keywordFormat = text_format(Qt.blue, QFont.Bold)\n        self.stringFormat = text_format(Qt.darkGreen)\n        self.defFormat = text_format(Qt.black, QFont.Bold)\n        self.commentFormat = text_format(Qt.lightGray)\n        self.decoratorFormat = text_format(Qt.darkGray)\n\n        self.keywords = list(keyword.kwlist)\n\n        self.rules = [(QRegExp(r\"\\b%s\\b\" % kwd), self.keywordFormat)\n                      for kwd in self.keywords] + \\\n                     [(QRegExp(r\"\\bdef\\s+([A-Za-z_]+[A-Za-z0-9_]+)\\s*\\(\"),\n                       self.defFormat),\n                      (QRegExp(r\"\\bclass\\s+([A-Za-z_]+[A-Za-z0-9_]+)\\s*\\(\"),\n                       self.defFormat),\n                      (QRegExp(r\"'.*'\"), self.stringFormat),\n                      (QRegExp(r'\".*\"'), self.stringFormat),\n                      (QRegExp(r\"#.*\"), self.commentFormat),\n                      (QRegExp(r\"@[A-Za-z_]+[A-Za-z0-9_]+\"),\n                       self.decoratorFormat)]\n\n        self.multilineStart = QRegExp(r\"(''')|\" + r'(\"\"\")')\n        self.multilineEnd = QRegExp(r\"(''')|\" + r'(\"\"\")')\n\n        super().__init__(parent)\n\n    def highlightBlock(self, text):\n        for pattern, fmt in self.rules:\n            exp = QRegExp(pattern)\n            index = exp.indexIn(text)\n            while index >= 0:\n                length = exp.matchedLength()\n                if exp.captureCount() > 0:\n                    self.setFormat(exp.pos(1), len(str(exp.cap(1))), fmt)\n                else:\n                    self.setFormat(exp.pos(0), len(str(exp.cap(0))), fmt)\n                index = exp.indexIn(text, index + length)\n\n        # Multi line strings\n        start = self.multilineStart\n        end = self.multilineEnd\n\n        self.setCurrentBlockState(0)\n        startIndex, skip = 0, 0\n        if self.previousBlockState() != 1:\n            startIndex, skip = start.indexIn(text), 3\n        while startIndex >= 0:\n            endIndex = end.indexIn(text, startIndex + skip)\n            if endIndex == -1:\n                self.setCurrentBlockState(1)\n                commentLen = len(text) - startIndex\n            else:\n                commentLen = endIndex - startIndex + 3\n            self.setFormat(startIndex, commentLen, self.stringFormat)\n            startIndex, skip = (start.indexIn(text,\n                                              startIndex + commentLen + 3),\n                                3)\n\n\nclass PythonScriptEditor(QPlainTextEdit):\n    INDENT = 4\n\n    def __init__(self, widget):\n        super().__init__()\n        self.widget = widget\n\n    def lastLine(self):\n        text = str(self.toPlainText())\n        pos = self.textCursor().position()\n        index = text.rfind(\"\\n\", 0, pos)\n        text = text[index: pos].lstrip(\"\\n\")\n        return text\n\n    def keyPressEvent(self, event):\n        if event.key() == Qt.Key_Return:\n            if event.modifiers() & (\n                    Qt.ShiftModifier | Qt.ControlModifier | Qt.MetaModifier):\n                self.widget.commit()\n                return\n            text = self.lastLine()\n            indent = len(text) - len(text.lstrip())\n            if text.strip() == \"pass\" or text.strip().startswith(\"return \"):\n                indent = max(0, indent - self.INDENT)\n            elif text.strip().endswith(\":\"):\n                indent += self.INDENT\n            super().keyPressEvent(event)\n            self.insertPlainText(\" \" * indent)\n        elif event.key() == Qt.Key_Tab:\n            self.insertPlainText(\" \" * self.INDENT)\n        elif event.key() == Qt.Key_Backspace:\n            text = self.lastLine()\n            if text and not text.strip():\n                cursor = self.textCursor()\n                for _ in range(min(self.INDENT, len(text))):\n                    cursor.deletePreviousChar()\n            else:\n                super().keyPressEvent(event)\n\n        else:\n            super().keyPressEvent(event)\n\n    def insertFromMimeData(self, source):\n        \"\"\"\n        Reimplemented from QPlainTextEdit.insertFromMimeData.\n        \"\"\"\n        urls = source.urls()\n        if urls:\n            self.pasteFile(urls[0])\n        else:\n            super().insertFromMimeData(source)\n\n    def pasteFile(self, url):\n        new = read_file_content(url.toLocalFile())\n        if new:\n            # inserting text like this allows undo\n            cursor = QTextCursor(self.document())\n            cursor.select(QTextCursor.Document)\n            cursor.insertText(new)\n\n\nclass PythonConsole(QPlainTextEdit, code.InteractiveConsole):\n    # `locals` is reasonably used as argument name\n    # pylint: disable=redefined-builtin\n    def __init__(self, locals=None, parent=None):\n        QPlainTextEdit.__init__(self, parent)\n        code.InteractiveConsole.__init__(self, locals)\n        self.newPromptPos = 0\n        self.history, self.historyInd = [\"\"], 0\n        self.loop = self.interact()\n        next(self.loop)\n\n    def setLocals(self, locals):\n        self.locals = locals\n\n    def updateLocals(self, locals):\n        self.locals.update(locals)\n\n    def interact(self, banner=None, _=None):\n        try:\n            sys.ps1\n        except AttributeError:\n            sys.ps1 = \">>> \"\n        try:\n            sys.ps2\n        except AttributeError:\n            sys.ps2 = \"... \"\n        cprt = ('Type \"help\", \"copyright\", \"credits\" or \"license\" '\n                'for more information.')\n        if banner is None:\n            self.write(\"Python %s on %s\\n%s\\n(%s)\\n\" %\n                       (sys.version, sys.platform, cprt,\n                        self.__class__.__name__))\n        else:\n            self.write(\"%s\\n\" % str(banner))\n        more = 0\n        while 1:\n            try:\n                if more:\n                    prompt = sys.ps2\n                else:\n                    prompt = sys.ps1\n                self.new_prompt(prompt)\n                yield\n                try:\n                    line = self.raw_input(prompt)\n                except EOFError:\n                    self.write(\"\\n\")\n                    break\n                else:\n                    more = self.push(line)\n            except KeyboardInterrupt:\n                self.write(\"\\nKeyboardInterrupt\\n\")\n                self.resetbuffer()\n                more = 0\n\n    def raw_input(self, prompt=\"\"):\n        input_str = str(self.document().lastBlock().previous().text())\n        return input_str[len(prompt):]\n\n    def new_prompt(self, prompt):\n        self.write(prompt)\n        self.newPromptPos = self.textCursor().position()\n        self.repaint()\n\n    def write(self, data):\n        cursor = QTextCursor(self.document())\n        cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor)\n        cursor.insertText(data)\n        self.setTextCursor(cursor)\n        self.ensureCursorVisible()\n\n    def writelines(self, lines):\n        for line in lines:\n            self.write(line)\n\n    def flush(self):\n        pass\n\n    def push(self, line):\n        if self.history[0] != line:\n            self.history.insert(0, line)\n        self.historyInd = 0\n\n        # prevent console errors to trigger error reporting & patch stdout, stderr\n        with patch('sys.excepthook', sys.__excepthook__),\\\n             patch('sys.stdout', self),\\\n             patch('sys.stderr', self):\n            return code.InteractiveConsole.push(self, line)\n\n    def setLine(self, line):\n        cursor = QTextCursor(self.document())\n        cursor.movePosition(QTextCursor.End)\n        cursor.setPosition(self.newPromptPos, QTextCursor.KeepAnchor)\n        cursor.removeSelectedText()\n        cursor.insertText(line)\n        self.setTextCursor(cursor)\n\n    def keyPressEvent(self, event):\n        if event.key() == Qt.Key_Return:\n            self.write(\"\\n\")\n            next(self.loop)\n        elif event.key() == Qt.Key_Up:\n            self.historyUp()\n        elif event.key() == Qt.Key_Down:\n            self.historyDown()\n        elif event.key() == Qt.Key_Tab:\n            self.complete()\n        elif event.key() in [Qt.Key_Left, Qt.Key_Backspace]:\n            if self.textCursor().position() > self.newPromptPos:\n                QPlainTextEdit.keyPressEvent(self, event)\n        else:\n            QPlainTextEdit.keyPressEvent(self, event)\n\n    def historyUp(self):\n        self.setLine(self.history[self.historyInd])\n        self.historyInd = min(self.historyInd + 1, len(self.history) - 1)\n\n    def historyDown(self):\n        self.setLine(self.history[self.historyInd])\n        self.historyInd = max(self.historyInd - 1, 0)\n\n    def complete(self):\n        pass\n\n    def _moveCursorToInputLine(self):\n        \"\"\"\n        Move the cursor to the input line if not already there. If the cursor\n        if already in the input line (at position greater or equal to\n        `newPromptPos`) it is left unchanged, otherwise it is moved at the\n        end.\n\n        \"\"\"\n        cursor = self.textCursor()\n        pos = cursor.position()\n        if pos < self.newPromptPos:\n            cursor.movePosition(QTextCursor.End)\n            self.setTextCursor(cursor)\n\n    def pasteCode(self, source):\n        \"\"\"\n        Paste source code into the console.\n        \"\"\"\n        self._moveCursorToInputLine()\n\n        for line in interleave(source.splitlines(), itertools.repeat(\"\\n\")):\n            if line != \"\\n\":\n                self.insertPlainText(line)\n            else:\n                self.write(\"\\n\")\n                next(self.loop)\n\n    def insertFromMimeData(self, source):\n        \"\"\"\n        Reimplemented from QPlainTextEdit.insertFromMimeData.\n        \"\"\"\n        if source.hasText():\n            self.pasteCode(str(source.text()))\n            return\n\n\nclass Script:\n    Modified = 1\n    MissingFromFilesystem = 2\n\n    def __init__(self, name, script, flags=0, filename=None):\n        self.name = name\n        self.script = script\n        self.flags = flags\n        self.filename = filename\n\n    def asdict(self) -> '_ScriptData':\n        return dict(name=self.name, script=self.script, filename=self.filename)\n\n    @classmethod\n    def fromdict(cls, state: '_ScriptData') -> 'Script':\n        return Script(state[\"name\"], state[\"script\"], filename=state[\"filename\"])\n\n\nclass ScriptItemDelegate(QStyledItemDelegate):\n    # pylint: disable=no-self-use\n    def displayText(self, script, _locale):\n        if script.flags & Script.Modified:\n            return \"*\" + script.name\n        else:\n            return script.name\n\n    def paint(self, painter, option, index):\n        script = index.data(Qt.DisplayRole)\n\n        if script.flags & Script.Modified:\n            option = QStyleOptionViewItem(option)\n            option.palette.setColor(QPalette.Text, QColor(Qt.red))\n            option.palette.setColor(QPalette.Highlight, QColor(Qt.darkRed))\n        super().paint(painter, option, index)\n\n    def createEditor(self, parent, _option, _index):\n        return QLineEdit(parent)\n\n    def setEditorData(self, editor, index):\n        script = index.data(Qt.DisplayRole)\n        editor.setText(script.name)\n\n    def setModelData(self, editor, model, index):\n        model[index.row()].name = str(editor.text())\n\n\ndef select_row(view, row):\n    \"\"\"\n    Select a `row` in an item view\n    \"\"\"\n    selmodel = view.selectionModel()\n    selmodel.select(view.model().index(row, 0),\n                    QItemSelectionModel.ClearAndSelect)\n\n\nif TYPE_CHECKING:\n    # pylint: disable=used-before-assignment\n    _ScriptData = TypedDict(\"_ScriptData\", {\n        \"name\": str, \"script\": str, \"filename\": Optional[str]\n    })\n\n\nclass OWPythonScript(OWWidget):\n    name = \"Python Script\"\n    description = \"Write a Python script and run it on input data or models.\"\n    icon = \"icons/PythonScript.svg\"\n    priority = 3150\n    keywords = [\"file\", \"program\"]\n\n    class Inputs:\n        data = Input(\"Data\", Table, replaces=[\"in_data\"],\n                     default=True, multiple=True)\n        learner = Input(\"Learner\", Learner, replaces=[\"in_learner\"],\n                        default=True, multiple=True)\n        classifier = Input(\"Classifier\", Model, replaces=[\"in_classifier\"],\n                           default=True, multiple=True)\n        object = Input(\"Object\", object, replaces=[\"in_object\"],\n                       default=False, multiple=True)\n\n    class Outputs:\n        data = Output(\"Data\", Table, replaces=[\"out_data\"])\n        learner = Output(\"Learner\", Learner, replaces=[\"out_learner\"])\n        classifier = Output(\"Classifier\", Model, replaces=[\"out_classifier\"])\n        object = Output(\"Object\", object, replaces=[\"out_object\"])\n\n    signal_names = (\"data\", \"learner\", \"classifier\", \"object\")\n\n    settings_version = 2\n    scriptLibrary: 'List[_ScriptData]' = Setting([{\n        \"name\": \"Hello world\",\n        \"script\": \"print('Hello world')\\n\",\n        \"filename\": None\n    }])\n    currentScriptIndex = Setting(0)\n    scriptText: Optional[str] = Setting(None, schema_only=True)\n    splitterState: Optional[bytes] = Setting(None)\n\n    # Widgets in the same schema share namespace through a dictionary whose\n    # key is self.signalManager. ales-erjavec expressed concern (and I fully\n    # agree!) about widget being aware of the outside world. I am leaving this\n    # anyway. If this causes any problems in the future, replace this with\n    # shared_namespaces = {} and thus use a common namespace for all instances\n    # of # PythonScript even if they are in different schemata.\n    shared_namespaces = weakref.WeakKeyDictionary()\n\n    class Error(OWWidget.Error):\n        pass\n\n    def __init__(self):\n        super().__init__()\n        self.libraryListSource = []\n\n        for name in self.signal_names:\n            setattr(self, name, {})\n\n        self._cachedDocuments = {}\n\n        self.infoBox = gui.vBox(self.controlArea, 'Info')\n        gui.label(\n            self.infoBox, self,\n            \"<p>Execute python script.</p><p>Input variables:<ul><li> \" +\n            \"<li>\".join(map(\"in_{0}, in_{0}s\".format, self.signal_names)) +\n            \"</ul></p><p>Output variables:<ul><li>\" +\n            \"<li>\".join(map(\"out_{0}\".format, self.signal_names)) +\n            \"</ul></p>\"\n        )\n\n        self.libraryList = itemmodels.PyListModel(\n            [], self,\n            flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)\n\n        self.libraryList.wrap(self.libraryListSource)\n\n        self.controlBox = gui.vBox(self.controlArea, 'Library')\n        self.controlBox.layout().setSpacing(1)\n\n        self.libraryView = QListView(\n            editTriggers=QListView.DoubleClicked |\n            QListView.EditKeyPressed,\n            sizePolicy=QSizePolicy(QSizePolicy.Ignored,\n                                   QSizePolicy.Preferred)\n        )\n        self.libraryView.setItemDelegate(ScriptItemDelegate(self))\n        self.libraryView.setModel(self.libraryList)\n\n        self.libraryView.selectionModel().selectionChanged.connect(\n            self.onSelectedScriptChanged\n        )\n        self.controlBox.layout().addWidget(self.libraryView)\n\n        w = itemmodels.ModelActionsWidget()\n\n        self.addNewScriptAction = action = QAction(\"+\", self)\n        action.setToolTip(\"Add a new script to the library\")\n        action.triggered.connect(self.onAddScript)\n        w.addAction(action)\n\n        action = QAction(unicodedata.lookup(\"MINUS SIGN\"), self)\n        action.setToolTip(\"Remove script from library\")\n        action.triggered.connect(self.onRemoveScript)\n        w.addAction(action)\n\n        action = QAction(\"Update\", self)\n        action.setToolTip(\"Save changes in the editor to library\")\n        action.setShortcut(QKeySequence(QKeySequence.Save))\n        action.triggered.connect(self.commitChangesToLibrary)\n        w.addAction(action)\n\n        action = QAction(\"More\", self, toolTip=\"More actions\")\n\n        new_from_file = QAction(\"Import Script from File\", self)\n        save_to_file = QAction(\"Save Selected Script to File\", self)\n        restore_saved = QAction(\"Undo Changes to Selected Script\", self)\n        save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))\n\n        new_from_file.triggered.connect(self.onAddScriptFromFile)\n        save_to_file.triggered.connect(self.saveScript)\n        restore_saved.triggered.connect(self.restoreSaved)\n\n        menu = QMenu(w)\n        menu.addAction(new_from_file)\n        menu.addAction(save_to_file)\n        menu.addAction(restore_saved)\n        action.setMenu(menu)\n        button = w.addAction(action)\n        button.setPopupMode(QToolButton.InstantPopup)\n\n        w.layout().setSpacing(1)\n\n        self.controlBox.layout().addWidget(w)\n\n        self.execute_button = gui.button(self.controlArea, self, 'Run', callback=self.commit)\n\n        run = QAction(\"Run script\", self, triggered=self.commit,\n                      shortcut=QKeySequence(Qt.ControlModifier | Qt.Key_R))\n        self.addAction(run)\n\n        self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)\n        self.mainArea.layout().addWidget(self.splitCanvas)\n\n        self.defaultFont = defaultFont = \\\n            \"Monaco\" if sys.platform == \"darwin\" else \"Courier\"\n\n        self.textBox = gui.vBox(self, 'Python Script')\n        self.splitCanvas.addWidget(self.textBox)\n        self.text = PythonScriptEditor(self)\n        self.textBox.layout().addWidget(self.text)\n\n        self.textBox.setAlignment(Qt.AlignVCenter)\n        self.text.setTabStopWidth(4)\n\n        self.text.modificationChanged[bool].connect(self.onModificationChanged)\n\n        self.saveAction = action = QAction(\"&Save\", self.text)\n        action.setToolTip(\"Save script to file\")\n        action.setShortcut(QKeySequence(QKeySequence.Save))\n        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)\n        action.triggered.connect(self.saveScript)\n\n        self.consoleBox = gui.vBox(self, 'Console')\n        self.splitCanvas.addWidget(self.consoleBox)\n        self.console = PythonConsole({}, self)\n        self.consoleBox.layout().addWidget(self.console)\n        self.console.document().setDefaultFont(QFont(defaultFont))\n        self.consoleBox.setAlignment(Qt.AlignBottom)\n        self.console.setTabStopWidth(4)\n        self.splitCanvas.setSizes([2, 1])\n        self.setAcceptDrops(True)\n        self.controlArea.layout().addStretch(10)\n\n        self._restoreState()\n        self.settingsAboutToBePacked.connect(self._saveState)\n\n    def sizeHint(self) -> QSize:\n        return super().sizeHint().expandedTo(QSize(800, 600))\n\n    def _restoreState(self):\n        self.libraryListSource = [Script.fromdict(s) for s in self.scriptLibrary]\n        self.libraryList.wrap(self.libraryListSource)\n        select_row(self.libraryView, self.currentScriptIndex)\n\n        if self.scriptText is not None:\n            current = self.text.toPlainText()\n            # do not mark scripts as modified\n            if self.scriptText != current:\n                self.text.document().setPlainText(self.scriptText)\n\n        if self.splitterState is not None:\n            self.splitCanvas.restoreState(QByteArray(self.splitterState))\n\n    def _saveState(self):\n        self.scriptLibrary = [s.asdict() for s in self.libraryListSource]\n        self.scriptText = self.text.toPlainText()\n        self.splitterState = bytes(self.splitCanvas.saveState())\n\n    def handle_input(self, obj, sig_id, signal):\n        dic = getattr(self, signal)\n        if obj is None:\n            if sig_id in dic.keys():\n                del dic[sig_id]\n        else:\n            dic[sig_id] = obj\n\n    @Inputs.data\n    def set_data(self, data, sig_id):\n        self.handle_input(data, sig_id, \"data\")\n\n    @Inputs.learner\n    def set_learner(self, data, sig_id):\n        self.handle_input(data, sig_id, \"learner\")\n\n    @Inputs.classifier\n    def set_classifier(self, data, sig_id):\n        self.handle_input(data, sig_id, \"classifier\")\n\n    @Inputs.object\n    def set_object(self, data, sig_id):\n        self.handle_input(data, sig_id, \"object\")\n\n    def handleNewSignals(self):\n        self.commit()\n\n    def selectedScriptIndex(self):\n        rows = self.libraryView.selectionModel().selectedRows()\n        if rows:\n            return [i.row() for i in rows][0]\n        else:\n            return None\n\n    def setSelectedScript(self, index):\n        select_row(self.libraryView, index)\n\n    def onAddScript(self, *_):\n        self.libraryList.append(Script(\"New script\", self.text.toPlainText(), 0))\n        self.setSelectedScript(len(self.libraryList) - 1)\n\n    def onAddScriptFromFile(self, *_):\n        filename, _ = QFileDialog.getOpenFileName(\n            self, 'Open Python Script',\n            os.path.expanduser(\"~/\"),\n            'Python files (*.py)\\nAll files(*.*)'\n        )\n        if filename:\n            name = os.path.basename(filename)\n            # TODO: use `tokenize.detect_encoding`\n            with open(filename, encoding=\"utf-8\") as f:\n                contents = f.read()\n            self.libraryList.append(Script(name, contents, 0, filename))\n            self.setSelectedScript(len(self.libraryList) - 1)\n\n    def onRemoveScript(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            del self.libraryList[index]\n            select_row(self.libraryView, max(index - 1, 0))\n\n    def onSaveScriptToFile(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.saveScript()\n\n    def onSelectedScriptChanged(self, selected, _deselected):\n        index = [i.row() for i in selected.indexes()]\n        if index:\n            current = index[0]\n            if current >= len(self.libraryList):\n                self.addNewScriptAction.trigger()\n                return\n\n            self.text.setDocument(self.documentForScript(current))\n            self.currentScriptIndex = current\n\n    def documentForScript(self, script=0):\n        if not isinstance(script, Script):\n            script = self.libraryList[script]\n        if script not in self._cachedDocuments:\n            doc = QTextDocument(self)\n            doc.setDocumentLayout(QPlainTextDocumentLayout(doc))\n            doc.setPlainText(script.script)\n            doc.setDefaultFont(QFont(self.defaultFont))\n            doc.highlighter = PythonSyntaxHighlighter(doc)\n            doc.modificationChanged[bool].connect(self.onModificationChanged)\n            doc.setModified(False)\n            self._cachedDocuments[script] = doc\n        return self._cachedDocuments[script]\n\n    def commitChangesToLibrary(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.libraryList[index].script = self.text.toPlainText()\n            self.text.document().setModified(False)\n            self.libraryList.emitDataChanged(index)\n\n    def onModificationChanged(self, modified):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.libraryList[index].flags = Script.Modified if modified else 0\n            self.libraryList.emitDataChanged(index)\n\n    def restoreSaved(self):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.text.document().setPlainText(self.libraryList[index].script)\n            self.text.document().setModified(False)\n\n    def saveScript(self):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            script = self.libraryList[index]\n            filename = script.filename\n        else:\n            filename = os.path.expanduser(\"~/\")\n\n        filename, _ = QFileDialog.getSaveFileName(\n            self, 'Save Python Script',\n            filename,\n            'Python files (*.py)\\nAll files(*.*)'\n        )\n\n        if filename:\n            fn = \"\"\n            head, tail = os.path.splitext(filename)\n            if not tail:\n                fn = head + \".py\"\n            else:\n                fn = filename\n\n            f = open(fn, 'w')\n            f.write(self.text.toPlainText())\n            f.close()\n\n    def initial_locals_state(self):\n        d = self.shared_namespaces.setdefault(self.signalManager, {}).copy()\n        for name in self.signal_names:\n            value = getattr(self, name)\n            all_values = list(value.values())\n            one_value = all_values[0] if len(all_values) == 1 else None\n            d[\"in_\" + name + \"s\"] = all_values\n            d[\"in_\" + name] = one_value\n        return d\n\n    def update_namespace(self, namespace):\n        not_saved = reduce(set.union,\n                           ({f\"in_{name}s\", f\"in_{name}\", f\"out_{name}\"}\n                            for name in self.signal_names))\n        self.shared_namespaces.setdefault(self.signalManager, {}).update(\n            {name: value for name, value in namespace.items()\n             if name not in not_saved})\n\n    def commit(self):\n        self.Error.clear()\n        lcls = self.initial_locals_state()\n        lcls[\"_script\"] = str(self.text.toPlainText())\n        self.console.updateLocals(lcls)\n        self.console.write(\"\\nRunning script:\\n\")\n        self.console.push(\"exec(_script)\")\n        self.console.new_prompt(sys.ps1)\n        self.update_namespace(self.console.locals)\n        for signal in self.signal_names:\n            out_var = self.console.locals.get(\"out_\" + signal)\n            signal_type = getattr(self.Outputs, signal).type\n            if not isinstance(out_var, signal_type) and out_var is not None:\n                self.Error.add_message(signal,\n                                       \"'{}' has to be an instance of '{}'.\".\n                                       format(signal, signal_type.__name__))\n                getattr(self.Error, signal)()\n                out_var = None\n            getattr(self.Outputs, signal).send(out_var)\n\n    def dragEnterEvent(self, event):  # pylint: disable=no-self-use\n        urls = event.mimeData().urls()\n        if urls:\n            # try reading the file as text\n            c = read_file_content(urls[0].toLocalFile(), limit=1000)\n            if c is not None:\n                event.acceptProposedAction()\n\n    def dropEvent(self, event):\n        \"\"\"Handle file drops\"\"\"\n        urls = event.mimeData().urls()\n        if urls:\n            self.text.pasteFile(urls[0])\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if version is not None and version < 2:\n            scripts = settings.pop(\"libraryListSource\")  # type: List[Script]\n            library = [dict(name=s.name, script=s.script, filename=s.filename)\n                       for s in scripts]  # type: List[_ScriptData]\n            settings[\"scriptLibrary\"] = library\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    WidgetPreview(OWPythonScript).run()\n",
            "header": {
                "file": {
                    "path": "Orange/widgets/data/owpythonscript.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "2f9089f27",
                "new_commit_hash": "47b088792",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/widgets/data/owpythonscript.py"
            },
            "plus_file": {
                "path": "b/Orange/widgets/data/owpythonscript.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 590,
                            "length": 7
                        },
                        "new_range": {
                            "start": 590,
                            "length": 6
                        },
                        "section": "class OWPythonScript(OWWidget):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        self.splitterState = bytes(self.splitCanvas.saveState())",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def handle_input(self, obj, sig_id, signal):",
                                "type": "context"
                            },
                            {
                                "content": "        sig_id = sig_id[0]",
                                "type": "deleted"
                            },
                            {
                                "content": "        dic = getattr(self, signal)",
                                "type": "context"
                            },
                            {
                                "content": "        if obj is None:",
                                "type": "context"
                            },
                            {
                                "content": "            if sig_id in dic.keys():",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/data/owpythonscript.py",
                            "type": "class",
                            "name": "OWPythonScript",
                            "content": "class OWPythonScript(OWWidget):\n    name = \"Python Script\"\n    description = \"Write a Python script and run it on input data or models.\"\n    icon = \"icons/PythonScript.svg\"\n    priority = 3150\n    keywords = [\"file\", \"program\"]\n\n    class Inputs:\n        data = Input(\"Data\", Table, replaces=[\"in_data\"],\n                     default=True, multiple=True)\n        learner = Input(\"Learner\", Learner, replaces=[\"in_learner\"],\n                        default=True, multiple=True)\n        classifier = Input(\"Classifier\", Model, replaces=[\"in_classifier\"],\n                           default=True, multiple=True)\n        object = Input(\"Object\", object, replaces=[\"in_object\"],\n                       default=False, multiple=True)\n\n    class Outputs:\n        data = Output(\"Data\", Table, replaces=[\"out_data\"])\n        learner = Output(\"Learner\", Learner, replaces=[\"out_learner\"])\n        classifier = Output(\"Classifier\", Model, replaces=[\"out_classifier\"])\n        object = Output(\"Object\", object, replaces=[\"out_object\"])\n\n    signal_names = (\"data\", \"learner\", \"classifier\", \"object\")\n\n    settings_version = 2\n    scriptLibrary: 'List[_ScriptData]' = Setting([{\n        \"name\": \"Hello world\",\n        \"script\": \"print('Hello world')\\n\",\n        \"filename\": None\n    }])\n    currentScriptIndex = Setting(0)\n    scriptText: Optional[str] = Setting(None, schema_only=True)\n    splitterState: Optional[bytes] = Setting(None)\n\n    # Widgets in the same schema share namespace through a dictionary whose\n    # key is self.signalManager. ales-erjavec expressed concern (and I fully\n    # agree!) about widget being aware of the outside world. I am leaving this\n    # anyway. If this causes any problems in the future, replace this with\n    # shared_namespaces = {} and thus use a common namespace for all instances\n    # of # PythonScript even if they are in different schemata.\n    shared_namespaces = weakref.WeakKeyDictionary()\n\n    class Error(OWWidget.Error):\n        pass\n\n    def __init__(self):\n        super().__init__()\n        self.libraryListSource = []\n\n        for name in self.signal_names:\n            setattr(self, name, {})\n\n        self._cachedDocuments = {}\n\n        self.infoBox = gui.vBox(self.controlArea, 'Info')\n        gui.label(\n            self.infoBox, self,\n            \"<p>Execute python script.</p><p>Input variables:<ul><li> \" +\n            \"<li>\".join(map(\"in_{0}, in_{0}s\".format, self.signal_names)) +\n            \"</ul></p><p>Output variables:<ul><li>\" +\n            \"<li>\".join(map(\"out_{0}\".format, self.signal_names)) +\n            \"</ul></p>\"\n        )\n\n        self.libraryList = itemmodels.PyListModel(\n            [], self,\n            flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)\n\n        self.libraryList.wrap(self.libraryListSource)\n\n        self.controlBox = gui.vBox(self.controlArea, 'Library')\n        self.controlBox.layout().setSpacing(1)\n\n        self.libraryView = QListView(\n            editTriggers=QListView.DoubleClicked |\n            QListView.EditKeyPressed,\n            sizePolicy=QSizePolicy(QSizePolicy.Ignored,\n                                   QSizePolicy.Preferred)\n        )\n        self.libraryView.setItemDelegate(ScriptItemDelegate(self))\n        self.libraryView.setModel(self.libraryList)\n\n        self.libraryView.selectionModel().selectionChanged.connect(\n            self.onSelectedScriptChanged\n        )\n        self.controlBox.layout().addWidget(self.libraryView)\n\n        w = itemmodels.ModelActionsWidget()\n\n        self.addNewScriptAction = action = QAction(\"+\", self)\n        action.setToolTip(\"Add a new script to the library\")\n        action.triggered.connect(self.onAddScript)\n        w.addAction(action)\n\n        action = QAction(unicodedata.lookup(\"MINUS SIGN\"), self)\n        action.setToolTip(\"Remove script from library\")\n        action.triggered.connect(self.onRemoveScript)\n        w.addAction(action)\n\n        action = QAction(\"Update\", self)\n        action.setToolTip(\"Save changes in the editor to library\")\n        action.setShortcut(QKeySequence(QKeySequence.Save))\n        action.triggered.connect(self.commitChangesToLibrary)\n        w.addAction(action)\n\n        action = QAction(\"More\", self, toolTip=\"More actions\")\n\n        new_from_file = QAction(\"Import Script from File\", self)\n        save_to_file = QAction(\"Save Selected Script to File\", self)\n        restore_saved = QAction(\"Undo Changes to Selected Script\", self)\n        save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))\n\n        new_from_file.triggered.connect(self.onAddScriptFromFile)\n        save_to_file.triggered.connect(self.saveScript)\n        restore_saved.triggered.connect(self.restoreSaved)\n\n        menu = QMenu(w)\n        menu.addAction(new_from_file)\n        menu.addAction(save_to_file)\n        menu.addAction(restore_saved)\n        action.setMenu(menu)\n        button = w.addAction(action)\n        button.setPopupMode(QToolButton.InstantPopup)\n\n        w.layout().setSpacing(1)\n\n        self.controlBox.layout().addWidget(w)\n\n        self.execute_button = gui.button(self.controlArea, self, 'Run', callback=self.commit)\n\n        run = QAction(\"Run script\", self, triggered=self.commit,\n                      shortcut=QKeySequence(Qt.ControlModifier | Qt.Key_R))\n        self.addAction(run)\n\n        self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)\n        self.mainArea.layout().addWidget(self.splitCanvas)\n\n        self.defaultFont = defaultFont = \\\n            \"Monaco\" if sys.platform == \"darwin\" else \"Courier\"\n\n        self.textBox = gui.vBox(self, 'Python Script')\n        self.splitCanvas.addWidget(self.textBox)\n        self.text = PythonScriptEditor(self)\n        self.textBox.layout().addWidget(self.text)\n\n        self.textBox.setAlignment(Qt.AlignVCenter)\n        self.text.setTabStopWidth(4)\n\n        self.text.modificationChanged[bool].connect(self.onModificationChanged)\n\n        self.saveAction = action = QAction(\"&Save\", self.text)\n        action.setToolTip(\"Save script to file\")\n        action.setShortcut(QKeySequence(QKeySequence.Save))\n        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)\n        action.triggered.connect(self.saveScript)\n\n        self.consoleBox = gui.vBox(self, 'Console')\n        self.splitCanvas.addWidget(self.consoleBox)\n        self.console = PythonConsole({}, self)\n        self.consoleBox.layout().addWidget(self.console)\n        self.console.document().setDefaultFont(QFont(defaultFont))\n        self.consoleBox.setAlignment(Qt.AlignBottom)\n        self.console.setTabStopWidth(4)\n        self.splitCanvas.setSizes([2, 1])\n        self.setAcceptDrops(True)\n        self.controlArea.layout().addStretch(10)\n\n        self._restoreState()\n        self.settingsAboutToBePacked.connect(self._saveState)\n\n    def sizeHint(self) -> QSize:\n        return super().sizeHint().expandedTo(QSize(800, 600))\n\n    def _restoreState(self):\n        self.libraryListSource = [Script.fromdict(s) for s in self.scriptLibrary]\n        self.libraryList.wrap(self.libraryListSource)\n        select_row(self.libraryView, self.currentScriptIndex)\n\n        if self.scriptText is not None:\n            current = self.text.toPlainText()\n            # do not mark scripts as modified\n            if self.scriptText != current:\n                self.text.document().setPlainText(self.scriptText)\n\n        if self.splitterState is not None:\n            self.splitCanvas.restoreState(QByteArray(self.splitterState))\n\n    def _saveState(self):\n        self.scriptLibrary = [s.asdict() for s in self.libraryListSource]\n        self.scriptText = self.text.toPlainText()\n        self.splitterState = bytes(self.splitCanvas.saveState())\n\n    def handle_input(self, obj, sig_id, signal):\n        sig_id = sig_id[0]\n        dic = getattr(self, signal)\n        if obj is None:\n            if sig_id in dic.keys():\n                del dic[sig_id]\n        else:\n            dic[sig_id] = obj\n\n    @Inputs.data\n    def set_data(self, data, sig_id):\n        self.handle_input(data, sig_id, \"data\")\n\n    @Inputs.learner\n    def set_learner(self, data, sig_id):\n        self.handle_input(data, sig_id, \"learner\")\n\n    @Inputs.classifier\n    def set_classifier(self, data, sig_id):\n        self.handle_input(data, sig_id, \"classifier\")\n\n    @Inputs.object\n    def set_object(self, data, sig_id):\n        self.handle_input(data, sig_id, \"object\")\n\n    def handleNewSignals(self):\n        self.commit()\n\n    def selectedScriptIndex(self):\n        rows = self.libraryView.selectionModel().selectedRows()\n        if rows:\n            return [i.row() for i in rows][0]\n        else:\n            return None\n\n    def setSelectedScript(self, index):\n        select_row(self.libraryView, index)\n\n    def onAddScript(self, *_):\n        self.libraryList.append(Script(\"New script\", self.text.toPlainText(), 0))\n        self.setSelectedScript(len(self.libraryList) - 1)\n\n    def onAddScriptFromFile(self, *_):\n        filename, _ = QFileDialog.getOpenFileName(\n            self, 'Open Python Script',\n            os.path.expanduser(\"~/\"),\n            'Python files (*.py)\\nAll files(*.*)'\n        )\n        if filename:\n            name = os.path.basename(filename)\n            # TODO: use `tokenize.detect_encoding`\n            with open(filename, encoding=\"utf-8\") as f:\n                contents = f.read()\n            self.libraryList.append(Script(name, contents, 0, filename))\n            self.setSelectedScript(len(self.libraryList) - 1)\n\n    def onRemoveScript(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            del self.libraryList[index]\n            select_row(self.libraryView, max(index - 1, 0))\n\n    def onSaveScriptToFile(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.saveScript()\n\n    def onSelectedScriptChanged(self, selected, _deselected):\n        index = [i.row() for i in selected.indexes()]\n        if index:\n            current = index[0]\n            if current >= len(self.libraryList):\n                self.addNewScriptAction.trigger()\n                return\n\n            self.text.setDocument(self.documentForScript(current))\n            self.currentScriptIndex = current\n\n    def documentForScript(self, script=0):\n        if not isinstance(script, Script):\n            script = self.libraryList[script]\n        if script not in self._cachedDocuments:\n            doc = QTextDocument(self)\n            doc.setDocumentLayout(QPlainTextDocumentLayout(doc))\n            doc.setPlainText(script.script)\n            doc.setDefaultFont(QFont(self.defaultFont))\n            doc.highlighter = PythonSyntaxHighlighter(doc)\n            doc.modificationChanged[bool].connect(self.onModificationChanged)\n            doc.setModified(False)\n            self._cachedDocuments[script] = doc\n        return self._cachedDocuments[script]\n\n    def commitChangesToLibrary(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.libraryList[index].script = self.text.toPlainText()\n            self.text.document().setModified(False)\n            self.libraryList.emitDataChanged(index)\n\n    def onModificationChanged(self, modified):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.libraryList[index].flags = Script.Modified if modified else 0\n            self.libraryList.emitDataChanged(index)\n\n    def restoreSaved(self):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.text.document().setPlainText(self.libraryList[index].script)\n            self.text.document().setModified(False)\n\n    def saveScript(self):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            script = self.libraryList[index]\n            filename = script.filename\n        else:\n            filename = os.path.expanduser(\"~/\")\n\n        filename, _ = QFileDialog.getSaveFileName(\n            self, 'Save Python Script',\n            filename,\n            'Python files (*.py)\\nAll files(*.*)'\n        )\n\n        if filename:\n            fn = \"\"\n            head, tail = os.path.splitext(filename)\n            if not tail:\n                fn = head + \".py\"\n            else:\n                fn = filename\n\n            f = open(fn, 'w')\n            f.write(self.text.toPlainText())\n            f.close()\n\n    def initial_locals_state(self):\n        d = self.shared_namespaces.setdefault(self.signalManager, {}).copy()\n        for name in self.signal_names:\n            value = getattr(self, name)\n            all_values = list(value.values())\n            one_value = all_values[0] if len(all_values) == 1 else None\n            d[\"in_\" + name + \"s\"] = all_values\n            d[\"in_\" + name] = one_value\n        return d\n\n    def update_namespace(self, namespace):\n        not_saved = reduce(set.union,\n                           ({f\"in_{name}s\", f\"in_{name}\", f\"out_{name}\"}\n                            for name in self.signal_names))\n        self.shared_namespaces.setdefault(self.signalManager, {}).update(\n            {name: value for name, value in namespace.items()\n             if name not in not_saved})\n\n    def commit(self):\n        self.Error.clear()\n        lcls = self.initial_locals_state()\n        lcls[\"_script\"] = str(self.text.toPlainText())\n        self.console.updateLocals(lcls)\n        self.console.write(\"\\nRunning script:\\n\")\n        self.console.push(\"exec(_script)\")\n        self.console.new_prompt(sys.ps1)\n        self.update_namespace(self.console.locals)\n        for signal in self.signal_names:\n            out_var = self.console.locals.get(\"out_\" + signal)\n            signal_type = getattr(self.Outputs, signal).type\n            if not isinstance(out_var, signal_type) and out_var is not None:\n                self.Error.add_message(signal,\n                                       \"'{}' has to be an instance of '{}'.\".\n                                       format(signal, signal_type.__name__))\n                getattr(self.Error, signal)()\n                out_var = None\n            getattr(self.Outputs, signal).send(out_var)\n\n    def dragEnterEvent(self, event):  # pylint: disable=no-self-use\n        urls = event.mimeData().urls()\n        if urls:\n            # try reading the file as text\n            c = read_file_content(urls[0].toLocalFile(), limit=1000)\n            if c is not None:\n                event.acceptProposedAction()\n\n    def dropEvent(self, event):\n        \"\"\"Handle file drops\"\"\"\n        urls = event.mimeData().urls()\n        if urls:\n            self.text.pasteFile(urls[0])\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if version is not None and version < 2:\n            scripts = settings.pop(\"libraryListSource\")  # type: List[Script]\n            library = [dict(name=s.name, script=s.script, filename=s.filename)\n                       for s in scripts]  # type: List[_ScriptData]\n            settings[\"scriptLibrary\"] = library",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 399,
                            "end_lineno": 787,
                            "parent": null
                        },
                        {
                            "file_name": "Orange/widgets/data/owpythonscript.py",
                            "type": "method",
                            "name": "OWPythonScript.handle_input",
                            "content": "class OWPythonScript(OWWidget):\n    name = \"Python Script\"\n    description = \"Write a Python script and run it on input data or models.\"\n    icon = \"icons/PythonScript.svg\"\n    priority = 3150\n    keywords = [\"file\", \"program\"]\n\n    class Inputs:\n        data = Input(\"Data\", Table, replaces=[\"in_data\"],\n                     default=True, multiple=True)\n        learner = Input(\"Learner\", Learner, replaces=[\"in_learner\"],\n                        default=True, multiple=True)\n        classifier = Input(\"Classifier\", Model, replaces=[\"in_classifier\"],\n                           default=True, multiple=True)\n        object = Input(\"Object\", object, replaces=[\"in_object\"],\n                       default=False, multiple=True)\n\n    class Outputs:\n        data = Output(\"Data\", Table, replaces=[\"out_data\"])\n        learner = Output(\"Learner\", Learner, replaces=[\"out_learner\"])\n        classifier = Output(\"Classifier\", Model, replaces=[\"out_classifier\"])\n        object = Output(\"Object\", object, replaces=[\"out_object\"])\n\n    signal_names = (\"data\", \"learner\", \"classifier\", \"object\")\n\n    settings_version = 2\n    scriptLibrary: 'List[_ScriptData]' = Setting([{\n        \"name\": \"Hello world\",\n        \"script\": \"print('Hello world')\\n\",\n        \"filename\": None\n    }])\n    currentScriptIndex = Setting(0)\n    scriptText: Optional[str] = Setting(None, schema_only=True)\n    splitterState: Optional[bytes] = Setting(None)\n\n    # Widgets in the same schema share namespace through a dictionary whose\n    # key is self.signalManager. ales-erjavec expressed concern (and I fully\n    # agree!) about widget being aware of the outside world. I am leaving this\n    # anyway. If this causes any problems in the future, replace this with\n    # shared_namespaces = {} and thus use a common namespace for all instances\n    # of # PythonScript even if they are in different schemata.\n    shared_namespaces = weakref.WeakKeyDictionary()\n\n    class Error(OWWidget.Error):\n        pass\n\n    def __init__(self):\n        super().__init__()\n        self.libraryListSource = []\n\n        for name in self.signal_names:\n            setattr(self, name, {})\n\n        self._cachedDocuments = {}\n\n        self.infoBox = gui.vBox(self.controlArea, 'Info')\n        gui.label(\n            self.infoBox, self,\n            \"<p>Execute python script.</p><p>Input variables:<ul><li> \" +\n            \"<li>\".join(map(\"in_{0}, in_{0}s\".format, self.signal_names)) +\n            \"</ul></p><p>Output variables:<ul><li>\" +\n            \"<li>\".join(map(\"out_{0}\".format, self.signal_names)) +\n            \"</ul></p>\"\n        )\n\n        self.libraryList = itemmodels.PyListModel(\n            [], self,\n            flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)\n\n        self.libraryList.wrap(self.libraryListSource)\n\n        self.controlBox = gui.vBox(self.controlArea, 'Library')\n        self.controlBox.layout().setSpacing(1)\n\n        self.libraryView = QListView(\n            editTriggers=QListView.DoubleClicked |\n            QListView.EditKeyPressed,\n            sizePolicy=QSizePolicy(QSizePolicy.Ignored,\n                                   QSizePolicy.Preferred)\n        )\n        self.libraryView.setItemDelegate(ScriptItemDelegate(self))\n        self.libraryView.setModel(self.libraryList)\n\n        self.libraryView.selectionModel().selectionChanged.connect(\n            self.onSelectedScriptChanged\n        )\n        self.controlBox.layout().addWidget(self.libraryView)\n\n        w = itemmodels.ModelActionsWidget()\n\n        self.addNewScriptAction = action = QAction(\"+\", self)\n        action.setToolTip(\"Add a new script to the library\")\n        action.triggered.connect(self.onAddScript)\n        w.addAction(action)\n\n        action = QAction(unicodedata.lookup(\"MINUS SIGN\"), self)\n        action.setToolTip(\"Remove script from library\")\n        action.triggered.connect(self.onRemoveScript)\n        w.addAction(action)\n\n        action = QAction(\"Update\", self)\n        action.setToolTip(\"Save changes in the editor to library\")\n        action.setShortcut(QKeySequence(QKeySequence.Save))\n        action.triggered.connect(self.commitChangesToLibrary)\n        w.addAction(action)\n\n        action = QAction(\"More\", self, toolTip=\"More actions\")\n\n        new_from_file = QAction(\"Import Script from File\", self)\n        save_to_file = QAction(\"Save Selected Script to File\", self)\n        restore_saved = QAction(\"Undo Changes to Selected Script\", self)\n        save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))\n\n        new_from_file.triggered.connect(self.onAddScriptFromFile)\n        save_to_file.triggered.connect(self.saveScript)\n        restore_saved.triggered.connect(self.restoreSaved)\n\n        menu = QMenu(w)\n        menu.addAction(new_from_file)\n        menu.addAction(save_to_file)\n        menu.addAction(restore_saved)\n        action.setMenu(menu)\n        button = w.addAction(action)\n        button.setPopupMode(QToolButton.InstantPopup)\n\n        w.layout().setSpacing(1)\n\n        self.controlBox.layout().addWidget(w)\n\n        self.execute_button = gui.button(self.controlArea, self, 'Run', callback=self.commit)\n\n        run = QAction(\"Run script\", self, triggered=self.commit,\n                      shortcut=QKeySequence(Qt.ControlModifier | Qt.Key_R))\n        self.addAction(run)\n\n        self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)\n        self.mainArea.layout().addWidget(self.splitCanvas)\n\n        self.defaultFont = defaultFont = \\\n            \"Monaco\" if sys.platform == \"darwin\" else \"Courier\"\n\n        self.textBox = gui.vBox(self, 'Python Script')\n        self.splitCanvas.addWidget(self.textBox)\n        self.text = PythonScriptEditor(self)\n        self.textBox.layout().addWidget(self.text)\n\n        self.textBox.setAlignment(Qt.AlignVCenter)\n        self.text.setTabStopWidth(4)\n\n        self.text.modificationChanged[bool].connect(self.onModificationChanged)\n\n        self.saveAction = action = QAction(\"&Save\", self.text)\n        action.setToolTip(\"Save script to file\")\n        action.setShortcut(QKeySequence(QKeySequence.Save))\n        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)\n        action.triggered.connect(self.saveScript)\n\n        self.consoleBox = gui.vBox(self, 'Console')\n        self.splitCanvas.addWidget(self.consoleBox)\n        self.console = PythonConsole({}, self)\n        self.consoleBox.layout().addWidget(self.console)\n        self.console.document().setDefaultFont(QFont(defaultFont))\n        self.consoleBox.setAlignment(Qt.AlignBottom)\n        self.console.setTabStopWidth(4)\n        self.splitCanvas.setSizes([2, 1])\n        self.setAcceptDrops(True)\n        self.controlArea.layout().addStretch(10)\n\n        self._restoreState()\n        self.settingsAboutToBePacked.connect(self._saveState)\n\n    def sizeHint(self) -> QSize:\n        return super().sizeHint().expandedTo(QSize(800, 600))\n\n    def _restoreState(self):\n        self.libraryListSource = [Script.fromdict(s) for s in self.scriptLibrary]\n        self.libraryList.wrap(self.libraryListSource)\n        select_row(self.libraryView, self.currentScriptIndex)\n\n        if self.scriptText is not None:\n            current = self.text.toPlainText()\n            # do not mark scripts as modified\n            if self.scriptText != current:\n                self.text.document().setPlainText(self.scriptText)\n\n        if self.splitterState is not None:\n            self.splitCanvas.restoreState(QByteArray(self.splitterState))\n\n    def _saveState(self):\n        self.scriptLibrary = [s.asdict() for s in self.libraryListSource]\n        self.scriptText = self.text.toPlainText()\n        self.splitterState = bytes(self.splitCanvas.saveState())\n\n    def handle_input(self, obj, sig_id, signal):\n        sig_id = sig_id[0]\n        dic = getattr(self, signal)\n        if obj is None:\n            if sig_id in dic.keys():\n                del dic[sig_id]\n        else:\n            dic[sig_id] = obj\n\n    @Inputs.data\n    def set_data(self, data, sig_id):\n        self.handle_input(data, sig_id, \"data\")\n\n    @Inputs.learner\n    def set_learner(self, data, sig_id):\n        self.handle_input(data, sig_id, \"learner\")\n\n    @Inputs.classifier\n    def set_classifier(self, data, sig_id):\n        self.handle_input(data, sig_id, \"classifier\")\n\n    @Inputs.object\n    def set_object(self, data, sig_id):\n        self.handle_input(data, sig_id, \"object\")\n\n    def handleNewSignals(self):\n        self.commit()\n\n    def selectedScriptIndex(self):\n        rows = self.libraryView.selectionModel().selectedRows()\n        if rows:\n            return [i.row() for i in rows][0]\n        else:\n            return None\n\n    def setSelectedScript(self, index):\n        select_row(self.libraryView, index)\n\n    def onAddScript(self, *_):\n        self.libraryList.append(Script(\"New script\", self.text.toPlainText(), 0))\n        self.setSelectedScript(len(self.libraryList) - 1)\n\n    def onAddScriptFromFile(self, *_):\n        filename, _ = QFileDialog.getOpenFileName(\n            self, 'Open Python Script',\n            os.path.expanduser(\"~/\"),\n            'Python files (*.py)\\nAll files(*.*)'\n        )\n        if filename:\n            name = os.path.basename(filename)\n            # TODO: use `tokenize.detect_encoding`\n            with open(filename, encoding=\"utf-8\") as f:\n                contents = f.read()\n            self.libraryList.append(Script(name, contents, 0, filename))\n            self.setSelectedScript(len(self.libraryList) - 1)\n\n    def onRemoveScript(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            del self.libraryList[index]\n            select_row(self.libraryView, max(index - 1, 0))\n\n    def onSaveScriptToFile(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.saveScript()\n\n    def onSelectedScriptChanged(self, selected, _deselected):\n        index = [i.row() for i in selected.indexes()]\n        if index:\n            current = index[0]\n            if current >= len(self.libraryList):\n                self.addNewScriptAction.trigger()\n                return\n\n            self.text.setDocument(self.documentForScript(current))\n            self.currentScriptIndex = current\n\n    def documentForScript(self, script=0):\n        if not isinstance(script, Script):\n            script = self.libraryList[script]\n        if script not in self._cachedDocuments:\n            doc = QTextDocument(self)\n            doc.setDocumentLayout(QPlainTextDocumentLayout(doc))\n            doc.setPlainText(script.script)\n            doc.setDefaultFont(QFont(self.defaultFont))\n            doc.highlighter = PythonSyntaxHighlighter(doc)\n            doc.modificationChanged[bool].connect(self.onModificationChanged)\n            doc.setModified(False)\n            self._cachedDocuments[script] = doc\n        return self._cachedDocuments[script]\n\n    def commitChangesToLibrary(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.libraryList[index].script = self.text.toPlainText()\n            self.text.document().setModified(False)\n            self.libraryList.emitDataChanged(index)\n\n    def onModificationChanged(self, modified):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.libraryList[index].flags = Script.Modified if modified else 0\n            self.libraryList.emitDataChanged(index)\n\n    def restoreSaved(self):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.text.document().setPlainText(self.libraryList[index].script)\n            self.text.document().setModified(False)\n\n    def saveScript(self):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            script = self.libraryList[index]\n            filename = script.filename\n        else:\n            filename = os.path.expanduser(\"~/\")\n\n        filename, _ = QFileDialog.getSaveFileName(\n            self, 'Save Python Script',\n            filename,\n            'Python files (*.py)\\nAll files(*.*)'\n        )\n\n        if filename:\n            fn = \"\"\n            head, tail = os.path.splitext(filename)\n            if not tail:\n                fn = head + \".py\"\n            else:\n                fn = filename\n\n            f = open(fn, 'w')\n            f.write(self.text.toPlainText())\n            f.close()\n\n    def initial_locals_state(self):\n        d = self.shared_namespaces.setdefault(self.signalManager, {}).copy()\n        for name in self.signal_names:\n            value = getattr(self, name)\n            all_values = list(value.values())\n            one_value = all_values[0] if len(all_values) == 1 else None\n            d[\"in_\" + name + \"s\"] = all_values\n            d[\"in_\" + name] = one_value\n        return d\n\n    def update_namespace(self, namespace):\n        not_saved = reduce(set.union,\n                           ({f\"in_{name}s\", f\"in_{name}\", f\"out_{name}\"}\n                            for name in self.signal_names))\n        self.shared_namespaces.setdefault(self.signalManager, {}).update(\n            {name: value for name, value in namespace.items()\n             if name not in not_saved})\n\n    def commit(self):\n        self.Error.clear()\n        lcls = self.initial_locals_state()\n        lcls[\"_script\"] = str(self.text.toPlainText())\n        self.console.updateLocals(lcls)\n        self.console.write(\"\\nRunning script:\\n\")\n        self.console.push(\"exec(_script)\")\n        self.console.new_prompt(sys.ps1)\n        self.update_namespace(self.console.locals)\n        for signal in self.signal_names:\n            out_var = self.console.locals.get(\"out_\" + signal)\n            signal_type = getattr(self.Outputs, signal).type\n            if not isinstance(out_var, signal_type) and out_var is not None:\n                self.Error.add_message(signal,\n                                       \"'{}' has to be an instance of '{}'.\".\n                                       format(signal, signal_type.__name__))\n                getattr(self.Error, signal)()\n                out_var = None\n            getattr(self.Outputs, signal).send(out_var)\n\n    def dragEnterEvent(self, event):  # pylint: disable=no-self-use\n        urls = event.mimeData().urls()\n        if urls:\n            # try reading the file as text\n            c = read_file_content(urls[0].toLocalFile(), limit=1000)\n            if c is not None:\n                event.acceptProposedAction()\n\n    def dropEvent(self, event):\n        \"\"\"Handle file drops\"\"\"\n        urls = event.mimeData().urls()\n        if urls:\n            self.text.pasteFile(urls[0])\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if version is not None and version < 2:\n            scripts = settings.pop(\"libraryListSource\")  # type: List[Script]\n            library = [dict(name=s.name, script=s.script, filename=s.filename)\n                       for s in scripts]  # type: List[_ScriptData]\n            settings[\"scriptLibrary\"] = library",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 592,
                            "end_lineno": 599,
                            "parent": {
                                "file_name": "Orange/widgets/data/owpythonscript.py",
                                "type": "class",
                                "name": "OWPythonScript",
                                "content": "class OWPythonScript(OWWidget):\n    name = \"Python Script\"\n    description = \"Write a Python script and run it on input data or models.\"\n    icon = \"icons/PythonScript.svg\"\n    priority = 3150\n    keywords = [\"file\", \"program\"]\n\n    class Inputs:\n        data = Input(\"Data\", Table, replaces=[\"in_data\"],\n                     default=True, multiple=True)\n        learner = Input(\"Learner\", Learner, replaces=[\"in_learner\"],\n                        default=True, multiple=True)\n        classifier = Input(\"Classifier\", Model, replaces=[\"in_classifier\"],\n                           default=True, multiple=True)\n        object = Input(\"Object\", object, replaces=[\"in_object\"],\n                       default=False, multiple=True)\n\n    class Outputs:\n        data = Output(\"Data\", Table, replaces=[\"out_data\"])\n        learner = Output(\"Learner\", Learner, replaces=[\"out_learner\"])\n        classifier = Output(\"Classifier\", Model, replaces=[\"out_classifier\"])\n        object = Output(\"Object\", object, replaces=[\"out_object\"])\n\n    signal_names = (\"data\", \"learner\", \"classifier\", \"object\")\n\n    settings_version = 2\n    scriptLibrary: 'List[_ScriptData]' = Setting([{\n        \"name\": \"Hello world\",\n        \"script\": \"print('Hello world')\\n\",\n        \"filename\": None\n    }])\n    currentScriptIndex = Setting(0)\n    scriptText: Optional[str] = Setting(None, schema_only=True)\n    splitterState: Optional[bytes] = Setting(None)\n\n    # Widgets in the same schema share namespace through a dictionary whose\n    # key is self.signalManager. ales-erjavec expressed concern (and I fully\n    # agree!) about widget being aware of the outside world. I am leaving this\n    # anyway. If this causes any problems in the future, replace this with\n    # shared_namespaces = {} and thus use a common namespace for all instances\n    # of # PythonScript even if they are in different schemata.\n    shared_namespaces = weakref.WeakKeyDictionary()\n\n    class Error(OWWidget.Error):\n        pass\n\n    def __init__(self):\n        super().__init__()\n        self.libraryListSource = []\n\n        for name in self.signal_names:\n            setattr(self, name, {})\n\n        self._cachedDocuments = {}\n\n        self.infoBox = gui.vBox(self.controlArea, 'Info')\n        gui.label(\n            self.infoBox, self,\n            \"<p>Execute python script.</p><p>Input variables:<ul><li> \" +\n            \"<li>\".join(map(\"in_{0}, in_{0}s\".format, self.signal_names)) +\n            \"</ul></p><p>Output variables:<ul><li>\" +\n            \"<li>\".join(map(\"out_{0}\".format, self.signal_names)) +\n            \"</ul></p>\"\n        )\n\n        self.libraryList = itemmodels.PyListModel(\n            [], self,\n            flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)\n\n        self.libraryList.wrap(self.libraryListSource)\n\n        self.controlBox = gui.vBox(self.controlArea, 'Library')\n        self.controlBox.layout().setSpacing(1)\n\n        self.libraryView = QListView(\n            editTriggers=QListView.DoubleClicked |\n            QListView.EditKeyPressed,\n            sizePolicy=QSizePolicy(QSizePolicy.Ignored,\n                                   QSizePolicy.Preferred)\n        )\n        self.libraryView.setItemDelegate(ScriptItemDelegate(self))\n        self.libraryView.setModel(self.libraryList)\n\n        self.libraryView.selectionModel().selectionChanged.connect(\n            self.onSelectedScriptChanged\n        )\n        self.controlBox.layout().addWidget(self.libraryView)\n\n        w = itemmodels.ModelActionsWidget()\n\n        self.addNewScriptAction = action = QAction(\"+\", self)\n        action.setToolTip(\"Add a new script to the library\")\n        action.triggered.connect(self.onAddScript)\n        w.addAction(action)\n\n        action = QAction(unicodedata.lookup(\"MINUS SIGN\"), self)\n        action.setToolTip(\"Remove script from library\")\n        action.triggered.connect(self.onRemoveScript)\n        w.addAction(action)\n\n        action = QAction(\"Update\", self)\n        action.setToolTip(\"Save changes in the editor to library\")\n        action.setShortcut(QKeySequence(QKeySequence.Save))\n        action.triggered.connect(self.commitChangesToLibrary)\n        w.addAction(action)\n\n        action = QAction(\"More\", self, toolTip=\"More actions\")\n\n        new_from_file = QAction(\"Import Script from File\", self)\n        save_to_file = QAction(\"Save Selected Script to File\", self)\n        restore_saved = QAction(\"Undo Changes to Selected Script\", self)\n        save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))\n\n        new_from_file.triggered.connect(self.onAddScriptFromFile)\n        save_to_file.triggered.connect(self.saveScript)\n        restore_saved.triggered.connect(self.restoreSaved)\n\n        menu = QMenu(w)\n        menu.addAction(new_from_file)\n        menu.addAction(save_to_file)\n        menu.addAction(restore_saved)\n        action.setMenu(menu)\n        button = w.addAction(action)\n        button.setPopupMode(QToolButton.InstantPopup)\n\n        w.layout().setSpacing(1)\n\n        self.controlBox.layout().addWidget(w)\n\n        self.execute_button = gui.button(self.controlArea, self, 'Run', callback=self.commit)\n\n        run = QAction(\"Run script\", self, triggered=self.commit,\n                      shortcut=QKeySequence(Qt.ControlModifier | Qt.Key_R))\n        self.addAction(run)\n\n        self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)\n        self.mainArea.layout().addWidget(self.splitCanvas)\n\n        self.defaultFont = defaultFont = \\\n            \"Monaco\" if sys.platform == \"darwin\" else \"Courier\"\n\n        self.textBox = gui.vBox(self, 'Python Script')\n        self.splitCanvas.addWidget(self.textBox)\n        self.text = PythonScriptEditor(self)\n        self.textBox.layout().addWidget(self.text)\n\n        self.textBox.setAlignment(Qt.AlignVCenter)\n        self.text.setTabStopWidth(4)\n\n        self.text.modificationChanged[bool].connect(self.onModificationChanged)\n\n        self.saveAction = action = QAction(\"&Save\", self.text)\n        action.setToolTip(\"Save script to file\")\n        action.setShortcut(QKeySequence(QKeySequence.Save))\n        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)\n        action.triggered.connect(self.saveScript)\n\n        self.consoleBox = gui.vBox(self, 'Console')\n        self.splitCanvas.addWidget(self.consoleBox)\n        self.console = PythonConsole({}, self)\n        self.consoleBox.layout().addWidget(self.console)\n        self.console.document().setDefaultFont(QFont(defaultFont))\n        self.consoleBox.setAlignment(Qt.AlignBottom)\n        self.console.setTabStopWidth(4)\n        self.splitCanvas.setSizes([2, 1])\n        self.setAcceptDrops(True)\n        self.controlArea.layout().addStretch(10)\n\n        self._restoreState()\n        self.settingsAboutToBePacked.connect(self._saveState)\n\n    def sizeHint(self) -> QSize:\n        return super().sizeHint().expandedTo(QSize(800, 600))\n\n    def _restoreState(self):\n        self.libraryListSource = [Script.fromdict(s) for s in self.scriptLibrary]\n        self.libraryList.wrap(self.libraryListSource)\n        select_row(self.libraryView, self.currentScriptIndex)\n\n        if self.scriptText is not None:\n            current = self.text.toPlainText()\n            # do not mark scripts as modified\n            if self.scriptText != current:\n                self.text.document().setPlainText(self.scriptText)\n\n        if self.splitterState is not None:\n            self.splitCanvas.restoreState(QByteArray(self.splitterState))\n\n    def _saveState(self):\n        self.scriptLibrary = [s.asdict() for s in self.libraryListSource]\n        self.scriptText = self.text.toPlainText()\n        self.splitterState = bytes(self.splitCanvas.saveState())\n\n    def handle_input(self, obj, sig_id, signal):\n        sig_id = sig_id[0]\n        dic = getattr(self, signal)\n        if obj is None:\n            if sig_id in dic.keys():\n                del dic[sig_id]\n        else:\n            dic[sig_id] = obj\n\n    @Inputs.data\n    def set_data(self, data, sig_id):\n        self.handle_input(data, sig_id, \"data\")\n\n    @Inputs.learner\n    def set_learner(self, data, sig_id):\n        self.handle_input(data, sig_id, \"learner\")\n\n    @Inputs.classifier\n    def set_classifier(self, data, sig_id):\n        self.handle_input(data, sig_id, \"classifier\")\n\n    @Inputs.object\n    def set_object(self, data, sig_id):\n        self.handle_input(data, sig_id, \"object\")\n\n    def handleNewSignals(self):\n        self.commit()\n\n    def selectedScriptIndex(self):\n        rows = self.libraryView.selectionModel().selectedRows()\n        if rows:\n            return [i.row() for i in rows][0]\n        else:\n            return None\n\n    def setSelectedScript(self, index):\n        select_row(self.libraryView, index)\n\n    def onAddScript(self, *_):\n        self.libraryList.append(Script(\"New script\", self.text.toPlainText(), 0))\n        self.setSelectedScript(len(self.libraryList) - 1)\n\n    def onAddScriptFromFile(self, *_):\n        filename, _ = QFileDialog.getOpenFileName(\n            self, 'Open Python Script',\n            os.path.expanduser(\"~/\"),\n            'Python files (*.py)\\nAll files(*.*)'\n        )\n        if filename:\n            name = os.path.basename(filename)\n            # TODO: use `tokenize.detect_encoding`\n            with open(filename, encoding=\"utf-8\") as f:\n                contents = f.read()\n            self.libraryList.append(Script(name, contents, 0, filename))\n            self.setSelectedScript(len(self.libraryList) - 1)\n\n    def onRemoveScript(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            del self.libraryList[index]\n            select_row(self.libraryView, max(index - 1, 0))\n\n    def onSaveScriptToFile(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.saveScript()\n\n    def onSelectedScriptChanged(self, selected, _deselected):\n        index = [i.row() for i in selected.indexes()]\n        if index:\n            current = index[0]\n            if current >= len(self.libraryList):\n                self.addNewScriptAction.trigger()\n                return\n\n            self.text.setDocument(self.documentForScript(current))\n            self.currentScriptIndex = current\n\n    def documentForScript(self, script=0):\n        if not isinstance(script, Script):\n            script = self.libraryList[script]\n        if script not in self._cachedDocuments:\n            doc = QTextDocument(self)\n            doc.setDocumentLayout(QPlainTextDocumentLayout(doc))\n            doc.setPlainText(script.script)\n            doc.setDefaultFont(QFont(self.defaultFont))\n            doc.highlighter = PythonSyntaxHighlighter(doc)\n            doc.modificationChanged[bool].connect(self.onModificationChanged)\n            doc.setModified(False)\n            self._cachedDocuments[script] = doc\n        return self._cachedDocuments[script]\n\n    def commitChangesToLibrary(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.libraryList[index].script = self.text.toPlainText()\n            self.text.document().setModified(False)\n            self.libraryList.emitDataChanged(index)\n\n    def onModificationChanged(self, modified):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.libraryList[index].flags = Script.Modified if modified else 0\n            self.libraryList.emitDataChanged(index)\n\n    def restoreSaved(self):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.text.document().setPlainText(self.libraryList[index].script)\n            self.text.document().setModified(False)\n\n    def saveScript(self):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            script = self.libraryList[index]\n            filename = script.filename\n        else:\n            filename = os.path.expanduser(\"~/\")\n\n        filename, _ = QFileDialog.getSaveFileName(\n            self, 'Save Python Script',\n            filename,\n            'Python files (*.py)\\nAll files(*.*)'\n        )\n\n        if filename:\n            fn = \"\"\n            head, tail = os.path.splitext(filename)\n            if not tail:\n                fn = head + \".py\"\n            else:\n                fn = filename\n\n            f = open(fn, 'w')\n            f.write(self.text.toPlainText())\n            f.close()\n\n    def initial_locals_state(self):\n        d = self.shared_namespaces.setdefault(self.signalManager, {}).copy()\n        for name in self.signal_names:\n            value = getattr(self, name)\n            all_values = list(value.values())\n            one_value = all_values[0] if len(all_values) == 1 else None\n            d[\"in_\" + name + \"s\"] = all_values\n            d[\"in_\" + name] = one_value\n        return d\n\n    def update_namespace(self, namespace):\n        not_saved = reduce(set.union,\n                           ({f\"in_{name}s\", f\"in_{name}\", f\"out_{name}\"}\n                            for name in self.signal_names))\n        self.shared_namespaces.setdefault(self.signalManager, {}).update(\n            {name: value for name, value in namespace.items()\n             if name not in not_saved})\n\n    def commit(self):\n        self.Error.clear()\n        lcls = self.initial_locals_state()\n        lcls[\"_script\"] = str(self.text.toPlainText())\n        self.console.updateLocals(lcls)\n        self.console.write(\"\\nRunning script:\\n\")\n        self.console.push(\"exec(_script)\")\n        self.console.new_prompt(sys.ps1)\n        self.update_namespace(self.console.locals)\n        for signal in self.signal_names:\n            out_var = self.console.locals.get(\"out_\" + signal)\n            signal_type = getattr(self.Outputs, signal).type\n            if not isinstance(out_var, signal_type) and out_var is not None:\n                self.Error.add_message(signal,\n                                       \"'{}' has to be an instance of '{}'.\".\n                                       format(signal, signal_type.__name__))\n                getattr(self.Error, signal)()\n                out_var = None\n            getattr(self.Outputs, signal).send(out_var)\n\n    def dragEnterEvent(self, event):  # pylint: disable=no-self-use\n        urls = event.mimeData().urls()\n        if urls:\n            # try reading the file as text\n            c = read_file_content(urls[0].toLocalFile(), limit=1000)\n            if c is not None:\n                event.acceptProposedAction()\n\n    def dropEvent(self, event):\n        \"\"\"Handle file drops\"\"\"\n        urls = event.mimeData().urls()\n        if urls:\n            self.text.pasteFile(urls[0])\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if version is not None and version < 2:\n            scripts = settings.pop(\"libraryListSource\")  # type: List[Script]\n            library = [dict(name=s.name, script=s.script, filename=s.filename)\n                       for s in scripts]  # type: List[_ScriptData]\n            settings[\"scriptLibrary\"] = library",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 399,
                                "end_lineno": 787,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring\nimport sys\n\nfrom AnyQt.QtCore import QMimeData, QUrl, QPoint, Qt\nfrom AnyQt.QtGui import QDragEnterEvent, QDropEvent\n\nfrom Orange.data import Table\nfrom Orange.classification import LogisticRegressionLearner\nfrom Orange.tests import named_file\nfrom Orange.widgets.data.owpythonscript import OWPythonScript, read_file_content, Script\nfrom Orange.widgets.tests.base import WidgetTest, DummySignalManager\nfrom Orange.widgets.widget import OWWidget\n\n\nclass TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n",
            "new_file_content": "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring\nimport sys\n\nfrom AnyQt.QtCore import QMimeData, QUrl, QPoint, Qt\nfrom AnyQt.QtGui import QDragEnterEvent, QDropEvent\n\nfrom Orange.data import Table\nfrom Orange.classification import LogisticRegressionLearner\nfrom Orange.tests import named_file\nfrom Orange.widgets.data.owpythonscript import OWPythonScript, read_file_content, Script\nfrom Orange.widgets.tests.base import WidgetTest, DummySignalManager\nfrom Orange.widgets.widget import OWWidget\n\n\nclass TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, 1)\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, 1)\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, 1)\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, 1)\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, 1)\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, 1)\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, 2)\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, 2)\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, 1)\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, 1, widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n",
            "header": {
                "file": {
                    "path": "Orange/widgets/data/tests/test_owpythonscript.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "bda77790d",
                "new_commit_hash": "6c505737e",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/widgets/data/tests/test_owpythonscript.py"
            },
            "plus_file": {
                "path": "b/Orange/widgets/data/tests/test_owpythonscript.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 32,
                            "length": 9
                        },
                        "new_range": {
                            "start": 32,
                            "length": 9
                        },
                        "section": "class TestOWPythonScript(WidgetTest):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                             (\"Classifier\", self.model),",
                                "type": "context"
                            },
                            {
                                "content": "                             (\"Object\", \"object\")):",
                                "type": "context"
                            },
                            {
                                "content": "            self.assertEqual(getattr(self.widget, input_.lower()), {})",
                                "type": "context"
                            },
                            {
                                "content": "            self.send_signal(input_, data, (1,))",
                                "type": "deleted"
                            },
                            {
                                "content": "            self.send_signal(input_, data, 1)",
                                "type": "added"
                            },
                            {
                                "content": "            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})",
                                "type": "context"
                            },
                            {
                                "content": "            self.send_signal(input_, None, (1,))",
                                "type": "deleted"
                            },
                            {
                                "content": "            self.send_signal(input_, None, 1)",
                                "type": "added"
                            },
                            {
                                "content": "            self.assertEqual(getattr(self.widget, input_.lower()), {})",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_outputs(self):",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                            "type": "method",
                            "name": "TestOWPythonScript.test_inputs",
                            "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 28,
                            "end_lineno": 38,
                            "parent": {
                                "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                                "type": "class",
                                "name": "TestOWPythonScript",
                                "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 16,
                                "end_lineno": 262,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                            "type": "class",
                            "name": "TestOWPythonScript",
                            "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 16,
                            "end_lineno": 262,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 45,
                            "length": 9
                        },
                        "new_range": {
                            "start": 45,
                            "length": 9
                        },
                        "section": "class TestOWPythonScript(WidgetTest):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                (\"Classifier\", self.model)):",
                                "type": "context"
                            },
                            {
                                "content": "            lsignal = signal.lower()",
                                "type": "context"
                            },
                            {
                                "content": "            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))",
                                "type": "context"
                            },
                            {
                                "content": "            self.send_signal(signal, data, (1,))",
                                "type": "deleted"
                            },
                            {
                                "content": "            self.send_signal(signal, data, 1)",
                                "type": "added"
                            },
                            {
                                "content": "            self.assertIs(self.get_output(signal), data)",
                                "type": "context"
                            },
                            {
                                "content": "            self.send_signal(signal, None, (1,))",
                                "type": "deleted"
                            },
                            {
                                "content": "            self.send_signal(signal, None, 1)",
                                "type": "added"
                            },
                            {
                                "content": "            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))",
                                "type": "context"
                            },
                            {
                                "content": "            self.widget.execute_button.click()",
                                "type": "context"
                            },
                            {
                                "content": "            self.assertIsNone(self.get_output(signal))",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                            "type": "method",
                            "name": "TestOWPythonScript.test_outputs",
                            "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 40,
                            "end_lineno": 53,
                            "parent": {
                                "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                                "type": "class",
                                "name": "TestOWPythonScript",
                                "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 16,
                                "end_lineno": 262,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                            "type": "class",
                            "name": "TestOWPythonScript",
                            "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 16,
                            "end_lineno": 262,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 73,
                            "length": 7
                        },
                        "new_range": {
                            "start": 73,
                            "length": 7
                        },
                        "section": "class TestOWPythonScript(WidgetTest):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                (\"Learner\", self.learner),",
                                "type": "context"
                            },
                            {
                                "content": "                (\"Classifier\", self.model)):",
                                "type": "context"
                            },
                            {
                                "content": "            lsignal = signal.lower()",
                                "type": "context"
                            },
                            {
                                "content": "            self.send_signal(signal, data, (1, ))",
                                "type": "deleted"
                            },
                            {
                                "content": "            self.send_signal(signal, data, 1)",
                                "type": "added"
                            },
                            {
                                "content": "            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))",
                                "type": "context"
                            },
                            {
                                "content": "            self.widget.execute_button.click()",
                                "type": "context"
                            },
                            {
                                "content": "            self.assertEqual(self.get_output(signal), None)",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                            "type": "class",
                            "name": "TestOWPythonScript",
                            "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 16,
                            "end_lineno": 262,
                            "parent": null
                        },
                        {
                            "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                            "type": "method",
                            "name": "TestOWPythonScript.test_wrong_outputs",
                            "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 65,
                            "end_lineno": 86,
                            "parent": {
                                "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                                "type": "class",
                                "name": "TestOWPythonScript",
                                "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 16,
                                "end_lineno": 262,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 98,
                            "length": 27
                        },
                        "new_range": {
                            "start": 98,
                            "length": 27
                        },
                        "section": "class TestOWPythonScript(WidgetTest):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        self.assertIsNone(console_locals[\"in_data\"])",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertEqual(console_locals[\"in_datas\"], [])",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        self.send_signal(\"Data\", self.iris, (1, ))",
                                "type": "deleted"
                            },
                            {
                                "content": "        self.send_signal(\"Data\", self.iris, 1)",
                                "type": "added"
                            },
                            {
                                "content": "        click()",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertIs(console_locals[\"in_data\"], self.iris)",
                                "type": "context"
                            },
                            {
                                "content": "        datas = console_locals[\"in_datas\"]",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertEqual(len(datas), 1)",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertIs(datas[0], self.iris)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        self.send_signal(\"Data\", titanic, (2, ))",
                                "type": "deleted"
                            },
                            {
                                "content": "        self.send_signal(\"Data\", titanic, 2)",
                                "type": "added"
                            },
                            {
                                "content": "        click()",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertIsNone(console_locals[\"in_data\"])",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},",
                                "type": "context"
                            },
                            {
                                "content": "                         {id(self.iris), id(titanic)})",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        self.send_signal(\"Data\", None, (2, ))",
                                "type": "deleted"
                            },
                            {
                                "content": "        self.send_signal(\"Data\", None, 2)",
                                "type": "added"
                            },
                            {
                                "content": "        click()",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertIs(console_locals[\"in_data\"], self.iris)",
                                "type": "context"
                            },
                            {
                                "content": "        datas = console_locals[\"in_datas\"]",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertEqual(len(datas), 1)",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertIs(datas[0], self.iris)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        self.send_signal(\"Data\", None, (1, ))",
                                "type": "deleted"
                            },
                            {
                                "content": "        self.send_signal(\"Data\", None, 1)",
                                "type": "added"
                            },
                            {
                                "content": "        click()",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertIsNone(console_locals[\"in_data\"])",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertEqual(console_locals[\"in_datas\"], [])",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                            "type": "method",
                            "name": "TestOWPythonScript.test_multiple_signals",
                            "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 91,
                            "end_lineno": 124,
                            "parent": {
                                "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                                "type": "class",
                                "name": "TestOWPythonScript",
                                "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 16,
                                "end_lineno": 262,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                            "type": "class",
                            "name": "TestOWPythonScript",
                            "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 16,
                            "end_lineno": 262,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 226,
                            "length": 7
                        },
                        "new_range": {
                            "start": 226,
                            "length": 7
                        },
                        "section": "class TestOWPythonScript(WidgetTest):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        self.signal_manager = DummySignalManager()",
                                "type": "context"
                            },
                            {
                                "content": "        widget3 = self.create_widget(OWPythonScript)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)",
                                "type": "deleted"
                            },
                            {
                                "content": "        self.send_signal(widget1.Inputs.data, self.iris, 1, widget=widget1)",
                                "type": "added"
                            },
                            {
                                "content": "        widget1.text.setPlainText(\"x = 42\\n\"",
                                "type": "context"
                            },
                            {
                                "content": "                                  \"out_data = in_data\\n\")",
                                "type": "context"
                            },
                            {
                                "content": "        widget1.execute_button.click()",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                            "type": "method",
                            "name": "TestOWPythonScript.test_shared_namespaces",
                            "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 223,
                            "end_lineno": 248,
                            "parent": {
                                "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                                "type": "class",
                                "name": "TestOWPythonScript",
                                "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 16,
                                "end_lineno": 262,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Orange/widgets/data/tests/test_owpythonscript.py",
                            "type": "class",
                            "name": "TestOWPythonScript",
                            "content": "class TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, (1,))\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, (1,))\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, (1,))\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, (1, ))\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, (1, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, (2, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, (2, ))\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, (1, ))\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, (1,), widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 16,
                            "end_lineno": 262,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "ecc15e9638ce3952fe22b62bc280f60af5789e9b^",
    "new_commit_hash": "ecc15e9638ce3952fe22b62bc280f60af5789e9b",
    "commit_message": "owpythonscript: Use signal id as is\n\nThe ids should be considered opaque identifiers and need to be used as\nsuch to keep track of inputs.",
    "commit_date": "2020-12-23T14:50:33+01:00",
    "metadata": {}
}
{
    "repo_name": "orange3",
    "new_commit_hash": "ecc15e9638ce3952fe22b62bc280f60af5789e9b",
    "test_file_codes": [
        "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring\nimport sys\n\nfrom AnyQt.QtCore import QMimeData, QUrl, QPoint, Qt\nfrom AnyQt.QtGui import QDragEnterEvent, QDropEvent\n\nfrom Orange.data import Table\nfrom Orange.classification import LogisticRegressionLearner\nfrom Orange.tests import named_file\nfrom Orange.widgets.data.owpythonscript import OWPythonScript, read_file_content, Script\nfrom Orange.widgets.tests.base import WidgetTest, DummySignalManager\nfrom Orange.widgets.widget import OWWidget\n\n\nclass TestOWPythonScript(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWPythonScript)\n        self.iris = Table(\"iris\")\n        self.learner = LogisticRegressionLearner()\n        self.model = self.learner(self.iris)\n\n    def tearDown(self):\n        # clear sys.last_*, these are set/used by interactive interpreter\n        sys.last_type = sys.last_value = sys.last_traceback = None\n        super().tearDown()\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n            self.send_signal(input_, data, 1)\n            self.assertEqual(getattr(self.widget, input_.lower()), {1: data})\n            self.send_signal(input_, None, 1)\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.send_signal(signal, data, 1)\n            self.assertIs(self.get_output(signal), data)\n            self.send_signal(signal, None, 1)\n            self.widget.text.setPlainText(\"print(in_{})\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIsNone(self.get_output(signal))\n\n    def test_local_variable(self):\n        \"\"\"Check if variable remains in locals after removed from script\"\"\"\n        self.widget.text.setPlainText(\"temp = 42\\nprint(temp)\")\n        self.widget.execute_button.click()\n        self.assertIn(\"42\", self.widget.console.toPlainText())\n        self.widget.text.setPlainText(\"print(temp)\")\n        self.widget.execute_button.click()\n        self.assertNotIn(\"NameError: name 'temp' is not defined\",\n                         self.widget.console.toPlainText())\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.send_signal(signal, data, 1)\n            self.widget.text.setPlainText(\"out_{} = 42\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertEqual(self.get_output(signal), None)\n            self.assertTrue(hasattr(self.widget.Error, lsignal))\n            self.assertTrue(getattr(self.widget.Error, lsignal).is_shown())\n\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n            self.widget.execute_button.click()\n            self.assertIs(self.get_output(signal), data)\n            self.assertFalse(getattr(self.widget.Error, lsignal).is_shown())\n\n    def test_owns_errors(self):\n        self.assertIsNot(self.widget.Error, OWWidget.Error)\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n\n        titanic = Table(\"titanic\")\n\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n        self.send_signal(\"Data\", self.iris, 1)\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", titanic, 2)\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual({id(obj) for obj in console_locals[\"in_datas\"]},\n                         {id(self.iris), id(titanic)})\n\n        self.send_signal(\"Data\", None, 2)\n        click()\n        self.assertIs(console_locals[\"in_data\"], self.iris)\n        datas = console_locals[\"in_datas\"]\n        self.assertEqual(len(datas), 1)\n        self.assertIs(datas[0], self.iris)\n\n        self.send_signal(\"Data\", None, 1)\n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n\n    def test_store_new_script(self):\n        self.widget.text.setPlainText(\"42\")\n        self.widget.onAddScript()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_restore_from_library(self):\n        before = self.widget.text.toPlainText()\n        self.widget.text.setPlainText(\"42\")\n        self.widget.restoreSaved()\n        script = self.widget.text.toPlainText()\n        self.assertEqual(before, script)\n\n    def test_store_current_script(self):\n        self.widget.text.setPlainText(\"42\")\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        self.widget = self.create_widget(OWPythonScript)\n        script = self.widget.text.toPlainText()\n        self.assertNotEqual(\"42\", script)\n        self.widget = self.create_widget(OWPythonScript, stored_settings=settings)\n        script = self.widget.text.toPlainText()\n        self.assertEqual(\"42\", script)\n\n    def test_read_file_content(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            # valid file opens\n            content = read_file_content(fn)\n            self.assertEqual(\"Content\", content)\n            # invalid utf-8 file does not\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            content = read_file_content(fn)\n            self.assertIsNone(content)\n\n    def test_script_insert_mime_text(self):\n        current = self.widget.text.toPlainText()\n        insert = \"test\\n\"\n        cursor = self.widget.text.cursor()\n        cursor.setPos(0, 0)\n        mime = QMimeData()\n        mime.setText(insert)\n        self.widget.text.insertFromMimeData(mime)\n        self.assertEqual(insert + current, self.widget.text.toPlainText())\n\n    def test_script_insert_mime_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            mime = QMimeData()\n            url = QUrl.fromLocalFile(fn)\n            mime.setUrls([url])\n            self.widget.text.insertFromMimeData(mime)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def test_dragEnterEvent_accepts_text(self):\n        with named_file(\"Content\", suffix=\".42\") as fn:\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertTrue(event.isAccepted())\n\n    def test_dragEnterEvent_rejects_binary(self):\n        with named_file(\"\", suffix=\".42\") as fn:\n            with open(fn, \"wb\") as f:\n                f.write(b\"\\xc3\\x28\")\n            event = self._drag_enter_event(QUrl.fromLocalFile(fn))\n            self.widget.dragEnterEvent(event)\n            self.assertFalse(event.isAccepted())\n\n    def _drag_enter_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n        return QDragEnterEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier)\n\n    def test_dropEvent_replaces_file(self):\n        with named_file(\"test\", suffix=\".42\") as fn:\n            previous = self.widget.text.toPlainText()\n            event = self._drop_event(QUrl.fromLocalFile(fn))\n            self.widget.dropEvent(event)\n            self.assertEqual(\"test\", self.widget.text.toPlainText())\n            self.widget.text.undo()\n            self.assertEqual(previous, self.widget.text.toPlainText())\n\n    def _drop_event(self, url):\n        # make sure data does not get garbage collected before it used\n        # pylint: disable=attribute-defined-outside-init\n        self.event_data = data = QMimeData()\n        data.setUrls([QUrl(url)])\n\n        return QDropEvent(\n            QPoint(0, 0), Qt.MoveAction, data,\n            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n\n        self.send_signal(widget1.Inputs.data, self.iris, 1, widget=widget1)\n        widget1.text.setPlainText(\"x = 42\\n\"\n                                  \"out_data = in_data\\n\")\n        widget1.execute_button.click()\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1),\n            self.iris)\n\n        widget2.text.setPlainText(\"out_object = 2 * x\\n\"\n                                  \"out_data = in_data\")\n        widget2.execute_button.click()\n        self.assertEqual(\n            self.get_output(widget1.Outputs.object, widget=widget2),\n            84)\n        self.assertIsNone(self.get_output(widget1.Outputs.data, widget=widget2))\n\n        sys.last_traceback = None\n        widget3.text.setPlainText(\"out_object = 2 * x\")\n        widget3.execute_button.click()\n        self.assertIsNotNone(sys.last_traceback)\n\n    def test_migrate(self):\n        w = self.create_widget(OWPythonScript, {\n            \"libraryListSource\": [Script(\"A\", \"1\")],\n            \"__version__\": 0\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n\n    def test_restore(self):\n        w = self.create_widget(OWPythonScript, {\n            \"scriptLibrary\": [dict(name=\"A\", script=\"1\", filename=None)],\n            \"__version__\": 2\n        })\n        self.assertEqual(w.libraryListSource[0].name, \"A\")\n"
    ],
    "test_file_names": [
        "test_1.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "Starting Orange installation attempts...\nAttempting installation with Python 3.7...\nrunning build_ext\nCompiling Orange/classification/_tree_scorers.pyx because it changed.\nCompiling Orange/data/_contingency.pyx because it changed.\nCompiling Orange/data/_io.pyx because it changed.\nCompiling Orange/data/_valuecount.pyx because it changed.\nCompiling Orange/data/_variable.pyx because it changed.\nCompiling Orange/distance/_distance.pyx because it changed.\nCompiling Orange/preprocess/_discretize.pyx because it changed.\nCompiling Orange/preprocess/_relieff.pyx because it changed.\nCompiling Orange/projection/_som.pyx because it changed.\n[1/9] Cythonizing Orange/classification/_tree_scorers.pyx\n[2/9] Cythonizing Orange/data/_contingency.pyx\n[3/9] Cythonizing Orange/data/_io.pyx\n[4/9] Cythonizing Orange/data/_valuecount.pyx\n[5/9] Cythonizing Orange/data/_variable.pyx\n[6/9] Cythonizing Orange/distance/_distance.pyx\n[7/9] Cythonizing Orange/preprocess/_discretize.pyx\n[8/9] Cythonizing Orange/preprocess/_relieff.pyx\n[9/9] Cythonizing Orange/projection/_som.pyx\nbuilding 'Orange.classification._tree_scorers' extension\ncreating build\ncreating build/temp.linux-x86_64-3.7\ncreating build/temp.linux-x86_64-3.7/Orange\ncreating build/temp.linux-x86_64-3.7/Orange/classification\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/classification/_tree_scorers.c -o build/temp.linux-x86_64-3.7/Orange/classification/_tree_scorers.o\ncreating build/lib.linux-x86_64-3.7\ncreating build/lib.linux-x86_64-3.7/Orange\ncreating build/lib.linux-x86_64-3.7/Orange/classification\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/classification/_tree_scorers.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._contingency' extension\ncreating build/temp.linux-x86_64-3.7/Orange/data\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_contingency.c -o build/temp.linux-x86_64-3.7/Orange/data/_contingency.o\ncreating build/lib.linux-x86_64-3.7/Orange/data\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_contingency.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._io' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_io.c -o build/temp.linux-x86_64-3.7/Orange/data/_io.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_io.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_io.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._valuecount' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_valuecount.c -o build/temp.linux-x86_64-3.7/Orange/data/_valuecount.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_valuecount.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._variable' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_variable.c -o build/temp.linux-x86_64-3.7/Orange/data/_variable.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_variable.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.distance._distance' extension\ncreating build/temp.linux-x86_64-3.7/Orange/distance\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/distance/_distance.c -o build/temp.linux-x86_64-3.7/Orange/distance/_distance.o\ncreating build/lib.linux-x86_64-3.7/Orange/distance\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/distance/_distance.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.preprocess._discretize' extension\ncreating build/temp.linux-x86_64-3.7/Orange/preprocess\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/preprocess/_discretize.c -o build/temp.linux-x86_64-3.7/Orange/preprocess/_discretize.o\ncreating build/lib.linux-x86_64-3.7/Orange/preprocess\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/preprocess/_discretize.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.preprocess._relieff' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/preprocess/_relieff.cpp -o build/temp.linux-x86_64-3.7/Orange/preprocess/_relieff.o\nc++ -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/preprocess/_relieff.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.projection._som' extension\ncreating build/temp.linux-x86_64-3.7/Orange/projection\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/projection/_som.c -o build/temp.linux-x86_64-3.7/Orange/projection/_som.o\ncreating build/lib.linux-x86_64-3.7/Orange/projection\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/projection/_som.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/projection/_som.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.classification._simple_tree' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/classification/_simple_tree.c -o build/temp.linux-x86_64-3.7/Orange/classification/_simple_tree.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/classification/_simple_tree.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.widgets.utils._grid_density' extension\ncreating build/temp.linux-x86_64-3.7/Orange/widgets\ncreating build/temp.linux-x86_64-3.7/Orange/widgets/utils\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/widgets/utils/_grid_density.cpp -o build/temp.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.o\ncreating build/lib.linux-x86_64-3.7/Orange/widgets\ncreating build/lib.linux-x86_64-3.7/Orange/widgets/utils\nc++ -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_io.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so -> Orange/distance\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/projection/_som.cpython-37m-x86_64-linux-gnu.so -> Orange/projection\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so -> Orange/widgets/utils\nrunning develop\nrunning egg_info\ncreating Orange3.egg-info\nwriting Orange3.egg-info/PKG-INFO\nwriting dependency_links to Orange3.egg-info/dependency_links.txt\nwriting entry points to Orange3.egg-info/entry_points.txt\nwriting requirements to Orange3.egg-info/requires.txt\nwriting top-level names to Orange3.egg-info/top_level.txt\nwriting manifest file 'Orange3.egg-info/SOURCES.txt'\nreading manifest file 'Orange3.egg-info/SOURCES.txt'\nreading manifest template 'MANIFEST.in'\nadding license file 'LICENSE'\nwriting manifest file 'Orange3.egg-info/SOURCES.txt'\nrunning build_ext\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_io.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so -> Orange/distance\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/projection/_som.cpython-37m-x86_64-linux-gnu.so -> Orange/projection\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so -> Orange/widgets/utils\nCreating /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/Orange3.egg-link (link to .)\nAdding Orange3 3.28.0.dev0+ecc15e9 to easy-install.pth file\nInstalling orange-canvas script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\n\nInstalled /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b\nProcessing dependencies for Orange3==3.28.0.dev0+ecc15e9\nSearching for XlsxWriter==3.2.0\nBest match: XlsxWriter 3.2.0\nAdding XlsxWriter 3.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for xlrd==2.0.1\nBest match: xlrd 2.0.1\nAdding xlrd 2.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for setuptools==59.8.0\nBest match: setuptools 59.8.0\nAdding setuptools 59.8.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for serverfiles==0.3.1\nBest match: serverfiles 0.3.1\nAdding serverfiles 0.3.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for scipy==1.7.3\nBest match: scipy 1.7.3\nAdding scipy 1.7.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for scikit-learn==1.0.2\nBest match: scikit-learn 1.0.2\nAdding scikit-learn 1.0.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for requests==2.31.0\nBest match: requests 2.31.0\nAdding requests 2.31.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for PyYAML==6.0.1\nBest match: PyYAML 6.0.1\nAdding PyYAML 6.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for python-louvain==0.16\nBest match: python-louvain 0.16\nAdding python-louvain 0.16 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for pyqtgraph==0.11.0\nBest match: pyqtgraph 0.11.0\nAdding pyqtgraph 0.11.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for pip==24.0\nBest match: pip 24.0\nAdding pip 24.0 to easy-install.pth file\nInstalling pip script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\nInstalling pip3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\nInstalling pip3.10 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for pandas==1.3.5\nBest match: pandas 1.3.5\nAdding pandas 1.3.5 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for orange-widget-base==4.22.0\nBest match: orange-widget-base 4.22.0\nAdding orange-widget-base 4.22.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for orange-canvas-core==0.1.35\nBest match: orange-canvas-core 0.1.35\nAdding orange-canvas-core 0.1.35 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for openpyxl==3.1.3\nBest match: openpyxl 3.1.3\nAdding openpyxl 3.1.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for openTSNE==1.0.1\nBest match: openTSNE 1.0.1\nAdding openTSNE 1.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for numpy==1.17.5\nBest match: numpy 1.17.5\nAdding numpy 1.17.5 to easy-install.pth file\nInstalling f2py script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\nInstalling f2py3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\nInstalling f2py3.7 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for networkx==2.6.3\nBest match: networkx 2.6.3\nAdding networkx 2.6.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for matplotlib==3.5.3\nBest match: matplotlib 3.5.3\nAdding matplotlib 3.5.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for keyrings.alt==4.2.0\nBest match: keyrings.alt 4.2.0\nAdding keyrings.alt 4.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for keyring==24.1.1\nBest match: keyring 24.1.1\nAdding keyring 24.1.1 to easy-install.pth file\nInstalling keyring script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for joblib==1.3.2\nBest match: joblib 1.3.2\nAdding joblib 1.3.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for httpx==0.14.3\nBest match: httpx 0.14.3\nAdding httpx 0.14.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for chardet==3.0.4\nBest match: chardet 3.0.4\nAdding chardet 3.0.4 to easy-install.pth file\nInstalling chardetect script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for Bottleneck==1.4.0\nBest match: Bottleneck 1.4.0\nAdding Bottleneck 1.4.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for baycomp==1.0.3\nBest match: baycomp 1.0.3\nAdding baycomp 1.0.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for PyQtWebEngine==5.15.6\nBest match: PyQtWebEngine 5.15.6\nAdding PyQtWebEngine 5.15.6 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for PyQt5==5.15.10\nBest match: PyQt5 5.15.10\nAdding PyQt5 5.15.10 to easy-install.pth file\nInstalling pylupdate5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\nInstalling pyrcc5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\nInstalling pyuic5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for AnyQt==0.2.0\nBest match: AnyQt 0.2.0\nAdding AnyQt 0.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for threadpoolctl==3.1.0\nBest match: threadpoolctl 3.1.0\nAdding threadpoolctl 3.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for idna==3.10\nBest match: idna 3.10\nAdding idna 3.10 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for certifi==2024.12.14\nBest match: certifi 2024.12.14\nAdding certifi 2024.12.14 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for urllib3==2.0.7\nBest match: urllib3 2.0.7\nAdding urllib3 2.0.7 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for charset-normalizer==3.4.1\nBest match: charset-normalizer 3.4.1\nAdding charset-normalizer 3.4.1 to easy-install.pth file\nInstalling normalizer script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for pytz==2024.2\nBest match: pytz 2024.2\nAdding pytz 2024.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for python-dateutil==2.9.0.post0\nBest match: python-dateutil 2.9.0.post0\nAdding python-dateutil 2.9.0.post0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for typing-extensions==4.7.1\nBest match: typing-extensions 4.7.1\nAdding typing-extensions 4.7.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for qasync==0.25.0\nBest match: qasync 0.25.0\nAdding qasync 0.25.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for dictdiffer==0.9.0\nBest match: dictdiffer 0.9.0\nAdding dictdiffer 0.9.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for requests-cache==1.1.1\nBest match: requests-cache 1.1.1\nAdding requests-cache 1.1.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for commonmark==0.9.1\nBest match: commonmark 0.9.1\nAdding commonmark 0.9.1 to easy-install.pth file\nInstalling cmark script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for docutils==0.20.1\nBest match: docutils 0.20.1\nAdding docutils 0.20.1 to easy-install.pth file\nInstalling docutils script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for importlib-metadata==6.7.0\nBest match: importlib-metadata 6.7.0\nAdding importlib-metadata 6.7.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for packaging==24.0\nBest match: packaging 24.0\nAdding packaging 24.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for et-xmlfile==1.1.0\nBest match: et-xmlfile 1.1.0\nAdding et-xmlfile 1.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for cycler==0.11.0\nBest match: cycler 0.11.0\nAdding cycler 0.11.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for pyparsing==3.1.4\nBest match: pyparsing 3.1.4\nAdding pyparsing 3.1.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for fonttools==4.38.0\nBest match: fonttools 4.38.0\nAdding fonttools 4.38.0 to easy-install.pth file\nInstalling fonttools script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\nInstalling pyftmerge script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\nInstalling pyftsubset script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\nInstalling ttx script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for kiwisolver==1.4.5\nBest match: kiwisolver 1.4.5\nAdding kiwisolver 1.4.5 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for Pillow==9.5.0\nBest match: Pillow 9.5.0\nAdding Pillow 9.5.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for jaraco.classes==3.2.3\nBest match: jaraco.classes 3.2.3\nAdding jaraco.classes 3.2.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for importlib-resources==5.12.0\nBest match: importlib-resources 5.12.0\nAdding importlib-resources 5.12.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for jeepney==0.8.0\nBest match: jeepney 0.8.0\nAdding jeepney 0.8.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for SecretStorage==3.3.3\nBest match: SecretStorage 3.3.3\nAdding SecretStorage 3.3.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for rfc3986==1.5.0\nBest match: rfc3986 1.5.0\nAdding rfc3986 1.5.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for httpcore==0.10.2\nBest match: httpcore 0.10.2\nAdding httpcore 0.10.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for sniffio==1.3.1\nBest match: sniffio 1.3.1\nAdding sniffio 1.3.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for PyQt5-sip==12.13.0\nBest match: PyQt5-sip 12.13.0\nAdding PyQt5-sip 12.13.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for PyQtWebEngine-Qt5==5.15.16\nBest match: PyQtWebEngine-Qt5 5.15.16\nAdding PyQtWebEngine-Qt5 5.15.16 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for PyQt5-Qt5==5.15.16\nBest match: PyQt5-Qt5 5.15.16\nAdding PyQt5-Qt5 5.15.16 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for six==1.17.0\nBest match: six 1.17.0\nAdding six 1.17.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for cattrs==23.1.2\nBest match: cattrs 23.1.2\nAdding cattrs 23.1.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for platformdirs==4.0.0\nBest match: platformdirs 4.0.0\nAdding platformdirs 4.0.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for attrs==24.2.0\nBest match: attrs 24.2.0\nAdding attrs 24.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for url-normalize==1.4.3\nBest match: url-normalize 1.4.3\nAdding url-normalize 1.4.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for zipp==3.15.0\nBest match: zipp 3.15.0\nAdding zipp 3.15.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for more-itertools==9.1.0\nBest match: more-itertools 9.1.0\nAdding more-itertools 9.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for cryptography==44.0.0\nBest match: cryptography 44.0.0\nAdding cryptography 44.0.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for h11==0.9.0\nBest match: h11 0.9.0\nAdding h11 0.9.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for exceptiongroup==1.2.2\nBest match: exceptiongroup 1.2.2\nAdding exceptiongroup 1.2.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for cffi==1.15.1\nBest match: cffi 1.15.1\nAdding cffi 1.15.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nSearching for pycparser==2.21\nBest match: pycparser 2.21\nAdding pycparser 2.21 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages\nFinished processing dependencies for Orange3==3.28.0.dev0+ecc15e9\nVerifying Orange installation...\n✅ Orange installation successful!\nSuccessfully installed orange using Python 3.7\n",
    "setup_res_stderr": "Using CPython 3.7.9\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 18 packages in 115ms\nPrepared 18 packages in 2ms\nInstalled 18 packages in 160ms\n + cython==0.29.37\n + exceptiongroup==1.2.2\n + importlib-metadata==6.7.0\n + iniconfig==2.0.0\n + numpy==1.17.5\n + packaging==24.0\n + pluggy==1.2.0\n + pyqt5==5.15.10\n + pyqt5-qt5==5.15.16\n + pyqt5-sip==12.13.0\n + pyqtwebengine==5.15.6\n + pyqtwebengine-qt5==5.15.16\n + pytest==7.4.4\n + setuptools==59.8.0\n + tomli==2.0.1\n + typing-extensions==4.7.1\n + wheel==0.42.0\n + zipp==3.15.0\nResolved 53 packages in 273ms\nInstalled 47 packages in 689ms\n + baycomp==1.0.3\n + bottleneck==1.4.0\n + certifi==2024.12.14\n + cffi==1.15.1\n + chardet==3.0.4\n + charset-normalizer==3.4.1\n + cryptography==44.0.0\n + cycler==0.11.0\n + et-xmlfile==1.1.0\n + fonttools==4.38.0\n + h11==0.9.0\n + httpcore==0.10.2\n + httpx==0.14.3\n + idna==3.10\n + importlib-resources==5.12.0\n + jaraco-classes==3.2.3\n + jeepney==0.8.0\n + joblib==1.3.2\n + keyring==24.1.1\n + keyrings-alt==4.2.0\n + kiwisolver==1.4.5\n + matplotlib==3.5.3\n + more-itertools==9.1.0\n + networkx==2.6.3\n + openpyxl==3.1.3\n + opentsne==1.0.1\n + pandas==1.3.5\n + pillow==9.5.0\n + pip==24.0\n + pycparser==2.21\n + pyparsing==3.1.4\n + python-dateutil==2.9.0.post0\n + python-louvain==0.16\n + pytz==2024.2\n + pyyaml==6.0.1\n + requests==2.31.0\n + rfc3986==1.5.0\n + scikit-learn==1.0.2\n + scipy==1.7.3\n + secretstorage==3.3.3\n + serverfiles==0.3.1\n + six==1.17.0\n + sniffio==1.3.1\n + threadpoolctl==3.1.0\n + urllib3==2.0.7\n + xlrd==2.0.1\n + xlsxwriter==3.2.0\nResolved 39 packages in 116ms\nInstalled 13 packages in 45ms\n + anyqt==0.2.0\n + attrs==24.2.0\n + cattrs==23.1.2\n + commonmark==0.9.1\n + dictdiffer==0.9.0\n + docutils==0.20.1\n + orange-canvas-core==0.1.35\n + orange-widget-base==4.22.0\n + platformdirs==4.0.0\n + pyqtgraph==0.11.0\n + qasync==0.25.0\n + requests-cache==1.1.1\n + url-normalize==1.4.3\nResolved 2 packages in 4ms\nInstalled 2 packages in 16ms\n + psycopg2==2.9.9\n + pymssql==2.3.2\nAudited 1 package in 21ms\nAudited 2 packages in 31ms\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/classification/_tree_scorers.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_2find_threshold_entropy’:\nOrange/classification/_tree_scorers.c:3413:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 3413 |   __pyx_t_7 = ((__pyx_v_N <= __pyx_v_min_leaf) != 0);\n      |                           ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_6find_threshold_MSE’:\nOrange/classification/_tree_scorers.c:4869:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 4869 |   __pyx_t_1 = ((__pyx_v_N <= __pyx_v_min_leaf) != 0);\n      |                           ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_8find_binarization_MSE’:\nOrange/classification/_tree_scorers.c:5615:43: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5615 |           for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {\n      |                                           ^\nOrange/classification/_tree_scorers.c:5736:39: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5736 |           __pyx_t_20 = ((__pyx_v_left >= __pyx_v_min_leaf) != 0);\n      |                                       ^~\nOrange/classification/_tree_scorers.c:5742:53: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5742 |           __pyx_t_20 = (((__pyx_v_N - __pyx_v_left) >= __pyx_v_min_leaf) != 0);\n      |                                                     ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_14compute_predictions_csr’:\nOrange/classification/_tree_scorers.c:7202:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7202 |         for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {\n      |                                         ^\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_16compute_predictions_csc’:\nOrange/classification/_tree_scorers.c:7857:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7857 |         for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {\n      |                                         ^\nOrange/classification/_tree_scorers.c:7917:143: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_int32_t’ {aka ‘int’} and ‘unsigned int’ [-Wsign-compare]\n 7917 |               __pyx_t_15 = (((*((__pyx_t_5numpy_int32_t *) ( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_14 * __pyx_v_indices.strides[0]) ))) != __pyx_v_i) != 0);\n      |                                                                                                                                               ^~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/data/_contingency.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/data/_io.c: In function ‘__pyx_pf_6Orange_4data_3_io_sparse_read_float.constprop’:\nOrange/data/_io.c:4120:43: warning: ‘__pyx_v_decs’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4120 |           __pyx_v_value = ((__pyx_v_value * __pyx_v_decs) + (__pyx_v_c & 0xf));\n      |                            ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/data/_io.c:4318:24: warning: ‘__pyx_v_value’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4318 |           __pyx_t_10 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 223, __pyx_L5_error)\n      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:683:40: warning: ‘__pyx_v_attr_index’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n  683 |   #define PyInt_FromLong               PyLong_FromLong\n      |                                        ^~~~~~~~~~~~~~~\nOrange/data/_io.c:1590:7: note: ‘__pyx_v_attr_index’ was declared here\n 1590 |   int __pyx_v_attr_index;\n      |       ^~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:3183:25: warning: ‘__pyx_v_atomp’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3183 |           __pyx_v_atomp = (__pyx_v_atomp + 1);\n      |           ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/data/_valuecount.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/distance/_distance.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/preprocess/_discretize.c:774:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/preprocess/_relieff.cpp:790:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/projection/_som.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_5update_hex’:\nOrange/projection/_som.c:3863:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3863 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:3862:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3862 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pf_6Orange_10projection_4_som_8update_sparse.constprop’:\nOrange/projection/_som.c:4934:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4934 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:4933:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4933 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_7get_winners_sparse’:\nOrange/projection/_som.c:4732:223: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4732 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_y;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:4307:7: note: ‘__pyx_v_win_y’ was declared here\n 4307 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:4721:223: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4721 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_x;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:4306:7: note: ‘__pyx_v_win_x’ was declared here\n 4306 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pf_6Orange_10projection_4_som_10update_sparse_hex.constprop’:\nOrange/projection/_som.c:5682:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 5682 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:5681:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 5681 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_1get_winners’:\nOrange/projection/_som.c:3184:223: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3184 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_y;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:2887:7: note: ‘__pyx_v_win_y’ was declared here\n 2887 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:3173:223: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3173 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_x;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:2886:7: note: ‘__pyx_v_win_x’ was declared here\n 2886 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_3update’:\nOrange/projection/_som.c:3357:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3357 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/classification/_simple_tree.c: In function ‘gain_ratio_c’:\nOrange/classification/_simple_tree.c:63:9: warning: implicit declaration of function ‘qsort_r’; did you mean ‘qsort’? [-Wimplicit-function-declaration]\n   63 |         qsort_r(base, nel, size, compar, thunk)\n      |         ^~~~~~~\nOrange/classification/_simple_tree.c:147:9: note: in expansion of macro ‘QSORT_R_FUNC’\n  147 |         QSORT_R_FUNC(examples, size, sizeof(struct Example), (void*) &compar_attr, compar_examples);\n      |         ^~~~~~~~~~~~\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/setuptools/command/easy_install.py:159: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.\n  EasyInstallDeprecationWarning,\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b/.venv/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.\n  setuptools.SetuptoolsDeprecationWarning,\nwarning: no files found matching 'README*' under directory 'Orange'\nwarning: no files found matching 'LICENSE' under directory 'Orange'\nwarning: no files found matching '*.basket' under directory 'Orange/datasets'\nwarning: no files found matching '*.js' under directory 'Orange/widgets'\nwarning: no files found matching '*.css' under directory 'Orange/widgets'\nwarning: no files found matching '*.html' under directory 'Orange/widgets'\nwarning: no files found matching 'COPYING'\n",
    "new_commit_res_code": 0,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.7.9, pytest-7.4.4, pluggy-1.2.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b\ncollected 24 items\n\nr2e_tests/test_1.py sss.....................                             [100%]\n\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_dragEnterEvent_accepts_text\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_dragEnterEvent_rejects_binary\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_dropEvent_replaces_file\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_image_export\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_inputs\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_local_variable\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_migrate\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_minimum_size\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_msg_base_class\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_multiple_signals\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_outputs\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_owns_errors\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_read_file_content\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_restore\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_restore_from_library\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_script_insert_mime_file\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_script_insert_mime_text\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_shared_namespaces\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_store_current_script\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_store_new_script\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_wrong_outputs\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:244: image exporting not tested as .widget was not set\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:238: minimum size not tested as .widget was not set\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:250: msg base class not tested as .widget was not set\n======================== 21 passed, 3 skipped in 4.15s =========================\nWidgets left: 0    Max widgets: 2128 \n\n",
    "new_commit_res_stderr": "",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.7.9, pytest-7.4.4, pluggy-1.2.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ecc15e9638ce3952fe22b62bc280f60af5789e9b\ncollected 24 items\n\nr2e_tests/test_1.py sss....F....FF......F..F                             [100%]\n\n=================================== FAILURES ===================================\n________________________ TestOWPythonScript.test_inputs ________________________\n\nself = <r2e_tests.test_1.TestOWPythonScript testMethod=test_inputs>\n\n    def test_inputs(self):\n        \"\"\"Check widget's inputs\"\"\"\n        for input_, data in ((\"Data\", self.iris),\n                             (\"Learner\", self.learner),\n                             (\"Classifier\", self.model),\n                             (\"Object\", \"object\")):\n            self.assertEqual(getattr(self.widget, input_.lower()), {})\n>           self.send_signal(input_, data, 1)\n\nr2e_tests/test_1.py:35: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:446: in send_signal\n    widget=widget, wait=wait)\n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:471: in send_signals\n    self._send_signal(widget, input, value, *args)\n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:490: in _send_signal\n    notify_input_helper(input, widget, value, *args, **kwargs)\n../../../../.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib/python3.7/functools.py:840: in wrapper\n    return dispatch(args[0].__class__)(*args, **kw)\n.venv/lib/python3.7/site-packages/orangewidget/utils/signals.py:735: in set_input_helper\n    handler(*args)\nOrange/widgets/data/owpythonscript.py:603: in set_data\n    self.handle_input(data, sig_id, \"data\")\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\nself = <Orange.widgets.data.owpythonscript.OWPythonScript object at 0x751f73e7deb0>\nobj = [[5.1, 3.5, 1.4, 0.2 | Iris-setosa],\n [4.9, 3.0, 1.4, 0.2 | Iris-setosa],\n [4.7, 3.2, 1.3, 0.2 | Iris-setosa],\n [4.6, 3.1, 1.5, 0.2 | Iris-setosa],\n [5.0, 3.6, 1.4, 0.2 | Iris-setosa],\n ...\n]\nsig_id = 1, signal = 'data'\n\n    def handle_input(self, obj, sig_id, signal):\n>       sig_id = sig_id[0]\nE       TypeError: 'int' object is not subscriptable\n\nOrange/widgets/data/owpythonscript.py:593: TypeError\n___________________ TestOWPythonScript.test_multiple_signals ___________________\n\nself = <r2e_tests.test_1.TestOWPythonScript testMethod=test_multiple_signals>\n\n    def test_multiple_signals(self):\n        click = self.widget.execute_button.click\n        console_locals = self.widget.console.locals\n    \n        titanic = Table(\"titanic\")\n    \n        click()\n        self.assertIsNone(console_locals[\"in_data\"])\n        self.assertEqual(console_locals[\"in_datas\"], [])\n    \n>       self.send_signal(\"Data\", self.iris, 1)\n\nr2e_tests/test_1.py:101: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:446: in send_signal\n    widget=widget, wait=wait)\n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:471: in send_signals\n    self._send_signal(widget, input, value, *args)\n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:490: in _send_signal\n    notify_input_helper(input, widget, value, *args, **kwargs)\n../../../../.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib/python3.7/functools.py:840: in wrapper\n    return dispatch(args[0].__class__)(*args, **kw)\n.venv/lib/python3.7/site-packages/orangewidget/utils/signals.py:735: in set_input_helper\n    handler(*args)\nOrange/widgets/data/owpythonscript.py:603: in set_data\n    self.handle_input(data, sig_id, \"data\")\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\nself = <Orange.widgets.data.owpythonscript.OWPythonScript object at 0x751f715ddb90>\nobj = [[5.1, 3.5, 1.4, 0.2 | Iris-setosa],\n [4.9, 3.0, 1.4, 0.2 | Iris-setosa],\n [4.7, 3.2, 1.3, 0.2 | Iris-setosa],\n [4.6, 3.1, 1.5, 0.2 | Iris-setosa],\n [5.0, 3.6, 1.4, 0.2 | Iris-setosa],\n ...\n]\nsig_id = 1, signal = 'data'\n\n    def handle_input(self, obj, sig_id, signal):\n>       sig_id = sig_id[0]\nE       TypeError: 'int' object is not subscriptable\n\nOrange/widgets/data/owpythonscript.py:593: TypeError\n_______________________ TestOWPythonScript.test_outputs ________________________\n\nself = <r2e_tests.test_1.TestOWPythonScript testMethod=test_outputs>\n\n    def test_outputs(self):\n        \"\"\"Check widget's outputs\"\"\"\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n            self.widget.text.setPlainText(\"out_{0} = in_{0}\".format(lsignal))\n>           self.send_signal(signal, data, 1)\n\nr2e_tests/test_1.py:48: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:446: in send_signal\n    widget=widget, wait=wait)\n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:471: in send_signals\n    self._send_signal(widget, input, value, *args)\n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:490: in _send_signal\n    notify_input_helper(input, widget, value, *args, **kwargs)\n../../../../.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib/python3.7/functools.py:840: in wrapper\n    return dispatch(args[0].__class__)(*args, **kw)\n.venv/lib/python3.7/site-packages/orangewidget/utils/signals.py:735: in set_input_helper\n    handler(*args)\nOrange/widgets/data/owpythonscript.py:603: in set_data\n    self.handle_input(data, sig_id, \"data\")\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\nself = <Orange.widgets.data.owpythonscript.OWPythonScript object at 0x751fc1d19b90>\nobj = [[5.1, 3.5, 1.4, 0.2 | Iris-setosa],\n [4.9, 3.0, 1.4, 0.2 | Iris-setosa],\n [4.7, 3.2, 1.3, 0.2 | Iris-setosa],\n [4.6, 3.1, 1.5, 0.2 | Iris-setosa],\n [5.0, 3.6, 1.4, 0.2 | Iris-setosa],\n ...\n]\nsig_id = 1, signal = 'data'\n\n    def handle_input(self, obj, sig_id, signal):\n>       sig_id = sig_id[0]\nE       TypeError: 'int' object is not subscriptable\n\nOrange/widgets/data/owpythonscript.py:593: TypeError\n__________________ TestOWPythonScript.test_shared_namespaces ___________________\n\nself = <r2e_tests.test_1.TestOWPythonScript testMethod=test_shared_namespaces>\n\n    def test_shared_namespaces(self):\n        widget1 = self.create_widget(OWPythonScript)\n        widget2 = self.create_widget(OWPythonScript)\n        self.signal_manager = DummySignalManager()\n        widget3 = self.create_widget(OWPythonScript)\n    \n>       self.send_signal(widget1.Inputs.data, self.iris, 1, widget=widget1)\n\nr2e_tests/test_1.py:229: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:446: in send_signal\n    widget=widget, wait=wait)\n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:471: in send_signals\n    self._send_signal(widget, input, value, *args)\n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:490: in _send_signal\n    notify_input_helper(input, widget, value, *args, **kwargs)\n../../../../.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib/python3.7/functools.py:840: in wrapper\n    return dispatch(args[0].__class__)(*args, **kw)\n.venv/lib/python3.7/site-packages/orangewidget/utils/signals.py:735: in set_input_helper\n    handler(*args)\nOrange/widgets/data/owpythonscript.py:603: in set_data\n    self.handle_input(data, sig_id, \"data\")\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\nself = <Orange.widgets.data.owpythonscript.OWPythonScript object at 0x751f70ae9af0>\nobj = [[5.1, 3.5, 1.4, 0.2 | Iris-setosa],\n [4.9, 3.0, 1.4, 0.2 | Iris-setosa],\n [4.7, 3.2, 1.3, 0.2 | Iris-setosa],\n [4.6, 3.1, 1.5, 0.2 | Iris-setosa],\n [5.0, 3.6, 1.4, 0.2 | Iris-setosa],\n ...\n]\nsig_id = 1, signal = 'data'\n\n    def handle_input(self, obj, sig_id, signal):\n>       sig_id = sig_id[0]\nE       TypeError: 'int' object is not subscriptable\n\nOrange/widgets/data/owpythonscript.py:593: TypeError\n____________________ TestOWPythonScript.test_wrong_outputs _____________________\n\nself = <r2e_tests.test_1.TestOWPythonScript testMethod=test_wrong_outputs>\n\n    def test_wrong_outputs(self):\n        \"\"\"\n        Error is shown when output variables are filled with wrong variable\n        types and also output variable is set to None. (GH-2308)\n        \"\"\"\n        self.assertEqual(len(self.widget.Error.active), 0)\n        for signal, data in (\n                (\"Data\", self.iris),\n                (\"Learner\", self.learner),\n                (\"Classifier\", self.model)):\n            lsignal = signal.lower()\n>           self.send_signal(signal, data, 1)\n\nr2e_tests/test_1.py:76: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:446: in send_signal\n    widget=widget, wait=wait)\n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:471: in send_signals\n    self._send_signal(widget, input, value, *args)\n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:490: in _send_signal\n    notify_input_helper(input, widget, value, *args, **kwargs)\n../../../../.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib/python3.7/functools.py:840: in wrapper\n    return dispatch(args[0].__class__)(*args, **kw)\n.venv/lib/python3.7/site-packages/orangewidget/utils/signals.py:735: in set_input_helper\n    handler(*args)\nOrange/widgets/data/owpythonscript.py:603: in set_data\n    self.handle_input(data, sig_id, \"data\")\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\nself = <Orange.widgets.data.owpythonscript.OWPythonScript object at 0x751f70a95550>\nobj = [[5.1, 3.5, 1.4, 0.2 | Iris-setosa],\n [4.9, 3.0, 1.4, 0.2 | Iris-setosa],\n [4.7, 3.2, 1.3, 0.2 | Iris-setosa],\n [4.6, 3.1, 1.5, 0.2 | Iris-setosa],\n [5.0, 3.6, 1.4, 0.2 | Iris-setosa],\n ...\n]\nsig_id = 1, signal = 'data'\n\n    def handle_input(self, obj, sig_id, signal):\n>       sig_id = sig_id[0]\nE       TypeError: 'int' object is not subscriptable\n\nOrange/widgets/data/owpythonscript.py:593: TypeError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_dragEnterEvent_accepts_text\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_dragEnterEvent_rejects_binary\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_dropEvent_replaces_file\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_image_export\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_local_variable\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_migrate\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_minimum_size\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_msg_base_class\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_owns_errors\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_read_file_content\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_restore\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_restore_from_library\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_script_insert_mime_file\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_script_insert_mime_text\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_store_current_script\nPASSED r2e_tests/test_1.py::TestOWPythonScript::test_store_new_script\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:244: image exporting not tested as .widget was not set\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:238: minimum size not tested as .widget was not set\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:250: msg base class not tested as .widget was not set\nFAILED r2e_tests/test_1.py::TestOWPythonScript::test_inputs - TypeError: 'int...\nFAILED r2e_tests/test_1.py::TestOWPythonScript::test_multiple_signals - TypeE...\nFAILED r2e_tests/test_1.py::TestOWPythonScript::test_outputs - TypeError: 'in...\nFAILED r2e_tests/test_1.py::TestOWPythonScript::test_shared_namespaces - Type...\nFAILED r2e_tests/test_1.py::TestOWPythonScript::test_wrong_outputs - TypeErro...\n=================== 5 failed, 16 passed, 3 skipped in 4.05s ====================\nWidgets left: 0    Max widgets: 2128 \n\n",
    "old_commit_res_stderr": ""
}
Orange/widgets/data/owpythonscript.py Orange/widgets/data/tests/test_owpythonscript.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** TypeError When Handling Signal ID in OWPythonScript Widget

**Description:**
Sending signals to the `OWPythonScript` widget results in a `TypeError` because the signal ID is incorrectly treated as a subscriptable object.

**Example:**
When a signal is sent with an integer ID, the widget attempts to access it as if it were a list or tuple.

```python
def test_inputs(self):
    for input_, data in (("Data", self.iris),
                         ("Learner", self.learner),
                         ("Classifier", self.model),
                         ("Object", "object")):
        self.send_signal(input_, data, 1)
```

**Expected Behavior:**
The widget should use the signal ID directly as an integer to track inputs without attempting to subscript it.

**Actual Behavior:**
A `TypeError` is raised because the widget tries to subscript the integer signal ID, leading to failures in multiple tests.

```
TypeError: 'int' object is not subscriptable
```

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### Orange/widgets/data/owpythonscript.py
import sys
import os
import code
import keyword
import itertools
import unicodedata
import weakref
from functools import reduce
from unittest.mock import patch

from typing import Optional, List, TYPE_CHECKING

from AnyQt.QtWidgets import (
    QPlainTextEdit, QListView, QSizePolicy, QMenu, QSplitter, QLineEdit,
    QAction, QToolButton, QFileDialog, QStyledItemDelegate,
    QStyleOptionViewItem, QPlainTextDocumentLayout
)
from AnyQt.QtGui import (
    QColor, QBrush, QPalette, QFont, QTextDocument,
    QSyntaxHighlighter, QTextCharFormat, QTextCursor, QKeySequence,
)
from AnyQt.QtCore import Qt, QRegExp, QByteArray, QItemSelectionModel, QSize

from Orange.data import Table
from Orange.base import Learner, Model
from Orange.util import interleave
from Orange.widgets import gui
from Orange.widgets.utils import itemmodels
from Orange.widgets.settings import Setting
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.widget import OWWidget, Input, Output

if TYPE_CHECKING:
    from typing_extensions import TypedDict

__all__ = ["OWPythonScript"]


def text_format(foreground=Qt.black, weight=QFont.Normal):
    fmt = QTextCharFormat()
    fmt.setForeground(QBrush(foreground))
    fmt.setFontWeight(weight)
    return fmt


def read_file_content(filename, limit=None):
    try:
        with open(filename, encoding="utf-8", errors='strict') as f:
            text = f.read(limit)
            return text
    except (OSError, UnicodeDecodeError):
        return None


class PythonSyntaxHighlighter(QSyntaxHighlighter):
    def __init__(self, parent=None):

        self.keywordFormat = text_format(Qt.blue, QFont.Bold)
        self.stringFormat = text_format(Qt.darkGreen)
        self.defFormat = text_format(Qt.black, QFont.Bold)
        self.commentFormat = text_format(Qt.lightGray)
        self.decoratorFormat = text_format(Qt.darkGray)

        self.keywords = list(keyword.kwlist)

        self.rules = [(QRegExp(r"\b%s\b" % kwd), self.keywordFormat)
                      for kwd in self.keywords] + \
                     [(QRegExp(r"\bdef\s+([A-Za-z_]+[A-Za-z0-9_]+)\s*\("),
                       self.defFormat),
                      (QRegExp(r"\bclass\s+([A-Za-z_]+[A-Za-z0-9_]+)\s*\("),
                       self.defFormat),
                      (QRegExp(r"'.*'"), self.stringFormat),
                      (QRegExp(r'".*"'), self.stringFormat),
                      (QRegExp(r"#.*"), self.commentFormat),
                      (QRegExp(r"@[A-Za-z_]+[A-Za-z0-9_]+"),
                       self.decoratorFormat)]

        self.multilineStart = QRegExp(r"(''')|" + r'(""")')
        self.multilineEnd = QRegExp(r"(''')|" + r'(""")')

        super().__init__(parent)

    def highlightBlock(self, text):
        for pattern, fmt in self.rules:
            exp = QRegExp(pattern)
            index = exp.indexIn(text)
            while index >= 0:
                length = exp.matchedLength()
                if exp.captureCount() > 0:
                    self.setFormat(exp.pos(1), len(str(exp.cap(1))), fmt)
                else:
                    self.setFormat(exp.pos(0), len(str(exp.cap(0))), fmt)
                index = exp.indexIn(text, index + length)

        # Multi line strings
        start = self.multilineStart
        end = self.multilineEnd

        self.setCurrentBlockState(0)
        startIndex, skip = 0, 0
        if self.previousBlockState() != 1:
            startIndex, skip = start.indexIn(text), 3
        while startIndex >= 0:
            endIndex = end.indexIn(text, startIndex + skip)
            if endIndex == -1:
                self.setCurrentBlockState(1)
                commentLen = len(text) - startIndex
            else:
                commentLen = endIndex - startIndex + 3
            self.setFormat(startIndex, commentLen, self.stringFormat)
            startIndex, skip = (start.indexIn(text,
                                              startIndex + commentLen + 3),
                                3)


class PythonScriptEditor(QPlainTextEdit):
    INDENT = 4

    def __init__(self, widget):
        super().__init__()
        self.widget = widget

    def lastLine(self):
        text = str(self.toPlainText())
        pos = self.textCursor().position()
        index = text.rfind("\n", 0, pos)
        text = text[index: pos].lstrip("\n")
        return text

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Return:
            if event.modifiers() & (
                    Qt.ShiftModifier | Qt.ControlModifier | Qt.MetaModifier):
                self.widget.commit()
                return
            text = self.lastLine()
            indent = len(text) - len(text.lstrip())
            if text.strip() == "pass" or text.strip().startswith("return "):
                indent = max(0, indent - self.INDENT)
            elif text.strip().endswith(":"):
                indent += self.INDENT
            super().keyPressEvent(event)
            self.insertPlainText(" " * indent)
        elif event.key() == Qt.Key_Tab:
            self.insertPlainText(" " * self.INDENT)
        elif event.key() == Qt.Key_Backspace:
            text = self.lastLine()
            if text and not text.strip():
                cursor = self.textCursor()
                for _ in range(min(self.INDENT, len(text))):
                    cursor.deletePreviousChar()
            else:
                super().keyPressEvent(event)

        else:
            super().keyPressEvent(event)

    def insertFromMimeData(self, source):
        """
        Reimplemented from QPlainTextEdit.insertFromMimeData.
        """
        urls = source.urls()
        if urls:
            self.pasteFile(urls[0])
        else:
            super().insertFromMimeData(source)

    def pasteFile(self, url):
        new = read_file_content(url.toLocalFile())
        if new:
            # inserting text like this allows undo
            cursor = QTextCursor(self.document())
            cursor.select(QTextCursor.Document)
            cursor.insertText(new)


class PythonConsole(QPlainTextEdit, code.InteractiveConsole):
    # `locals` is reasonably used as argument name
    # pylint: disable=redefined-builtin
    def __init__(self, locals=None, parent=None):
        QPlainTextEdit.__init__(self, parent)
        code.InteractiveConsole.__init__(self, locals)
        self.newPromptPos = 0
        self.history, self.historyInd = [""], 0
        self.loop = self.interact()
        next(self.loop)

    def setLocals(self, locals):
        self.locals = locals

    def updateLocals(self, locals):
        self.locals.update(locals)

    def interact(self, banner=None, _=None):
        try:
            sys.ps1
        except AttributeError:
            sys.ps1 = ">>> "
        try:
            sys.ps2
        except AttributeError:
            sys.ps2 = "... "
        cprt = ('Type "help", "copyright", "credits" or "license" '
                'for more information.')
        if banner is None:
            self.write("Python %s on %s\n%s\n(%s)\n" %
                       (sys.version, sys.platform, cprt,
                        self.__class__.__name__))
        else:
            self.write("%s\n" % str(banner))
        more = 0
        while 1:
            try:
                if more:
                    prompt = sys.ps2
                else:
                    prompt = sys.ps1
                self.new_prompt(prompt)
                yield
                try:
                    line = self.raw_input(prompt)
                except EOFError:
                    self.write("\n")
                    break
                else:
                    more = self.push(line)
            except KeyboardInterrupt:
                self.write("\nKeyboardInterrupt\n")
                self.resetbuffer()
                more = 0

    def raw_input(self, prompt=""):
        input_str = str(self.document().lastBlock().previous().text())
        return input_str[len(prompt):]

    def new_prompt(self, prompt):
        self.write(prompt)
        self.newPromptPos = self.textCursor().position()
        self.repaint()

    def write(self, data):
        cursor = QTextCursor(self.document())
        cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor)
        cursor.insertText(data)
        self.setTextCursor(cursor)
        self.ensureCursorVisible()

    def writelines(self, lines):
        for line in lines:
            self.write(line)

    def flush(self):
        pass

    def push(self, line):
        if self.history[0] != line:
            self.history.insert(0, line)
        self.historyInd = 0

        # prevent console errors to trigger error reporting & patch stdout, stderr
        with patch('sys.excepthook', sys.__excepthook__),\
             patch('sys.stdout', self),\
             patch('sys.stderr', self):
            return code.InteractiveConsole.push(self, line)

    def setLine(self, line):
        cursor = QTextCursor(self.document())
        cursor.movePosition(QTextCursor.End)
        cursor.setPosition(self.newPromptPos, QTextCursor.KeepAnchor)
        cursor.removeSelectedText()
        cursor.insertText(line)
        self.setTextCursor(cursor)

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Return:
            self.write("\n")
            next(self.loop)
        elif event.key() == Qt.Key_Up:
            self.historyUp()
        elif event.key() == Qt.Key_Down:
            self.historyDown()
        elif event.key() == Qt.Key_Tab:
            self.complete()
        elif event.key() in [Qt.Key_Left, Qt.Key_Backspace]:
            if self.textCursor().position() > self.newPromptPos:
                QPlainTextEdit.keyPressEvent(self, event)
        else:
            QPlainTextEdit.keyPressEvent(self, event)

    def historyUp(self):
        self.setLine(self.history[self.historyInd])
        self.historyInd = min(self.historyInd + 1, len(self.history) - 1)

    def historyDown(self):
        self.setLine(self.history[self.historyInd])
        self.historyInd = max(self.historyInd - 1, 0)

    def complete(self):
        pass

    def _moveCursorToInputLine(self):
        """
        Move the cursor to the input line if not already there. If the cursor
        if already in the input line (at position greater or equal to
        `newPromptPos`) it is left unchanged, otherwise it is moved at the
        end.

        """
        cursor = self.textCursor()
        pos = cursor.position()
        if pos < self.newPromptPos:
            cursor.movePosition(QTextCursor.End)
            self.setTextCursor(cursor)

    def pasteCode(self, source):
        """
        Paste source code into the console.
        """
        self._moveCursorToInputLine()

        for line in interleave(source.splitlines(), itertools.repeat("\n")):
            if line != "\n":
                self.insertPlainText(line)
            else:
                self.write("\n")
                next(self.loop)

    def insertFromMimeData(self, source):
        """
        Reimplemented from QPlainTextEdit.insertFromMimeData.
        """
        if source.hasText():
            self.pasteCode(str(source.text()))
            return


class Script:
    Modified = 1
    MissingFromFilesystem = 2

    def __init__(self, name, script, flags=0, filename=None):
        self.name = name
        self.script = script
        self.flags = flags
        self.filename = filename

    def asdict(self) -> '_ScriptData':
        return dict(name=self.name, script=self.script, filename=self.filename)

    @classmethod
    def fromdict(cls, state: '_ScriptData') -> 'Script':
        return Script(state["name"], state["script"], filename=state["filename"])


class ScriptItemDelegate(QStyledItemDelegate):
    # pylint: disable=no-self-use
    def displayText(self, script, _locale):
        if script.flags & Script.Modified:
            return "*" + script.name
        else:
            return script.name

    def paint(self, painter, option, index):
        script = index.data(Qt.DisplayRole)

        if script.flags & Script.Modified:
            option = QStyleOptionViewItem(option)
            option.palette.setColor(QPalette.Text, QColor(Qt.red))
            option.palette.setColor(QPalette.Highlight, QColor(Qt.darkRed))
        super().paint(painter, option, index)

    def createEditor(self, parent, _option, _index):
        return QLineEdit(parent)

    def setEditorData(self, editor, index):
        script = index.data(Qt.DisplayRole)
        editor.setText(script.name)

    def setModelData(self, editor, model, index):
        model[index.row()].name = str(editor.text())


def select_row(view, row):
    """
    Select a `row` in an item view
    """
    selmodel = view.selectionModel()
    selmodel.select(view.model().index(row, 0),
                    QItemSelectionModel.ClearAndSelect)


if TYPE_CHECKING:
    # pylint: disable=used-before-assignment
    _ScriptData = TypedDict("_ScriptData", {
        "name": str, "script": str, "filename": Optional[str]
    })


class OWPythonScript(OWWidget):
    name = "Python Script"
    description = "Write a Python script and run it on input data or models."
    icon = "icons/PythonScript.svg"
    priority = 3150
    keywords = ["file", "program"]

    class Inputs:
        data = Input("Data", Table, replaces=["in_data"],
                     default=True, multiple=True)
        learner = Input("Learner", Learner, replaces=["in_learner"],
                        default=True, multiple=True)
        classifier = Input("Classifier", Model, replaces=["in_classifier"],
                           default=True, multiple=True)
        object = Input("Object", object, replaces=["in_object"],
                       default=False, multiple=True)

    class Outputs:
        data = Output("Data", Table, replaces=["out_data"])
        learner = Output("Learner", Learner, replaces=["out_learner"])
        classifier = Output("Classifier", Model, replaces=["out_classifier"])
        object = Output("Object", object, replaces=["out_object"])

    signal_names = ("data", "learner", "classifier", "object")

    settings_version = 2
    scriptLibrary: 'List[_ScriptData]' = Setting([{
        "name": "Hello world",
        "script": "print('Hello world')\n",
        "filename": None
    }])
    currentScriptIndex = Setting(0)
    scriptText: Optional[str] = Setting(None, schema_only=True)
    splitterState: Optional[bytes] = Setting(None)

    # Widgets in the same schema share namespace through a dictionary whose
    # key is self.signalManager. ales-erjavec expressed concern (and I fully
    # agree!) about widget being aware of the outside world. I am leaving this
    # anyway. If this causes any problems in the future, replace this with
    # shared_namespaces = {} and thus use a common namespace for all instances
    # of # PythonScript even if they are in different schemata.
    shared_namespaces = weakref.WeakKeyDictionary()

    class Error(OWWidget.Error):
        pass

    def __init__(self):
        super().__init__()
        self.libraryListSource = []

        for name in self.signal_names:
            setattr(self, name, {})

        self._cachedDocuments = {}

        self.infoBox = gui.vBox(self.controlArea, 'Info')
        gui.label(
            self.infoBox, self,
            "<p>Execute python script.</p><p>Input variables:<ul><li> " +
            "<li>".join(map("in_{0}, in_{0}s".format, self.signal_names)) +
            "</ul></p><p>Output variables:<ul><li>" +
            "<li>".join(map("out_{0}".format, self.signal_names)) +
            "</ul></p>"
        )

        self.libraryList = itemmodels.PyListModel(
            [], self,
            flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)

        self.libraryList.wrap(self.libraryListSource)

        self.controlBox = gui.vBox(self.controlArea, 'Library')
        self.controlBox.layout().setSpacing(1)

        self.libraryView = QListView(
            editTriggers=QListView.DoubleClicked |
            QListView.EditKeyPressed,
            sizePolicy=QSizePolicy(QSizePolicy.Ignored,
                                   QSizePolicy.Preferred)
        )
        self.libraryView.setItemDelegate(ScriptItemDelegate(self))
        self.libraryView.setModel(self.libraryList)

        self.libraryView.selectionModel().selectionChanged.connect(
            self.onSelectedScriptChanged
        )
        self.controlBox.layout().addWidget(self.libraryView)

        w = itemmodels.ModelActionsWidget()

        self.addNewScriptAction = action = QAction("+", self)
        action.setToolTip("Add a new script to the library")
        action.triggered.connect(self.onAddScript)
        w.addAction(action)

        action = QAction(unicodedata.lookup("MINUS SIGN"), self)
        action.setToolTip("Remove script from library")
        action.triggered.connect(self.onRemoveScript)
        w.addAction(action)

        action = QAction("Update", self)
        action.setToolTip("Save changes in the editor to library")
        action.setShortcut(QKeySequence(QKeySequence.Save))
        action.triggered.connect(self.commitChangesToLibrary)
        w.addAction(action)

        action = QAction("More", self, toolTip="More actions")

        new_from_file = QAction("Import Script from File", self)
        save_to_file = QAction("Save Selected Script to File", self)
        restore_saved = QAction("Undo Changes to Selected Script", self)
        save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))

        new_from_file.triggered.connect(self.onAddScriptFromFile)
        save_to_file.triggered.connect(self.saveScript)
        restore_saved.triggered.connect(self.restoreSaved)

        menu = QMenu(w)
        menu.addAction(new_from_file)
        menu.addAction(save_to_file)
        menu.addAction(restore_saved)
        action.setMenu(menu)
        button = w.addAction(action)
        button.setPopupMode(QToolButton.InstantPopup)

        w.layout().setSpacing(1)

        self.controlBox.layout().addWidget(w)

        self.execute_button = gui.button(self.controlArea, self, 'Run', callback=self.commit)

        run = QAction("Run script", self, triggered=self.commit,
                      shortcut=QKeySequence(Qt.ControlModifier | Qt.Key_R))
        self.addAction(run)

        self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)
        self.mainArea.layout().addWidget(self.splitCanvas)

        self.defaultFont = defaultFont = \
            "Monaco" if sys.platform == "darwin" else "Courier"

        self.textBox = gui.vBox(self, 'Python Script')
        self.splitCanvas.addWidget(self.textBox)
        self.text = PythonScriptEditor(self)
        self.textBox.layout().addWidget(self.text)

        self.textBox.setAlignment(Qt.AlignVCenter)
        self.text.setTabStopWidth(4)

        self.text.modificationChanged[bool].connect(self.onModificationChanged)

        self.saveAction = action = QAction("&Save", self.text)
        action.setToolTip("Save script to file")
        action.setShortcut(QKeySequence(QKeySequence.Save))
        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        action.triggered.connect(self.saveScript)

        self.consoleBox = gui.vBox(self, 'Console')
        self.splitCanvas.addWidget(self.consoleBox)
        self.console = PythonConsole({}, self)
        self.consoleBox.layout().addWidget(self.console)
        self.console.document().setDefaultFont(QFont(defaultFont))
        self.consoleBox.setAlignment(Qt.AlignBottom)
        self.console.setTabStopWidth(4)
        self.splitCanvas.setSizes([2, 1])
        self.setAcceptDrops(True)
        self.controlArea.layout().addStretch(10)

        self._restoreState()
        self.settingsAboutToBePacked.connect(self._saveState)

    def sizeHint(self) -> QSize:
        return super().sizeHint().expandedTo(QSize(800, 600))

    def _restoreState(self):
        self.libraryListSource = [Script.fromdict(s) for s in self.scriptLibrary]
        self.libraryList.wrap(self.libraryListSource)
        select_row(self.libraryView, self.currentScriptIndex)

        if self.scriptText is not None:
            current = self.text.toPlainText()
            # do not mark scripts as modified
            if self.scriptText != current:
                self.text.document().setPlainText(self.scriptText)

        if self.splitterState is not None:
            self.splitCanvas.restoreState(QByteArray(self.splitterState))

    def _saveState(self):
        self.scriptLibrary = [s.asdict() for s in self.libraryListSource]
        self.scriptText = self.text.toPlainText()
        self.splitterState = bytes(self.splitCanvas.saveState())

    def handle_input(self, obj, sig_id, signal):
        sig_id = sig_id[0]
        dic = getattr(self, signal)
        if obj is None:
            if sig_id in dic.keys():
                del dic[sig_id]
        else:
            dic[sig_id] = obj

    @Inputs.data
    def set_data(self, data, sig_id):
        self.handle_input(data, sig_id, "data")

    @Inputs.learner
    def set_learner(self, data, sig_id):
        self.handle_input(data, sig_id, "learner")

    @Inputs.classifier
    def set_classifier(self, data, sig_id):
        self.handle_input(data, sig_id, "classifier")

    @Inputs.object
    def set_object(self, data, sig_id):
        self.handle_input(data, sig_id, "object")

    def handleNewSignals(self):
        self.commit()

    def selectedScriptIndex(self):
        rows = self.libraryView.selectionModel().selectedRows()
        if rows:
            return [i.row() for i in rows][0]
        else:
            return None

    def setSelectedScript(self, index):
        select_row(self.libraryView, index)

    def onAddScript(self, *_):
        self.libraryList.append(Script("New script", self.text.toPlainText(), 0))
        self.setSelectedScript(len(self.libraryList) - 1)

    def onAddScriptFromFile(self, *_):
        filename, _ = QFileDialog.getOpenFileName(
            self, 'Open Python Script',
            os.path.expanduser("~/"),
            'Python files (*.py)\nAll files(*.*)'
        )
        if filename:
            name = os.path.basename(filename)
            # TODO: use `tokenize.detect_encoding`
            with open(filename, encoding="utf-8") as f:
                contents = f.read()
            self.libraryList.append(Script(name, contents, 0, filename))
            self.setSelectedScript(len(self.libraryList) - 1)

    def onRemoveScript(self, *_):
        index = self.selectedScriptIndex()
        if index is not None:
            del self.libraryList[index]
            select_row(self.libraryView, max(index - 1, 0))

    def onSaveScriptToFile(self, *_):
        index = self.selectedScriptIndex()
        if index is not None:
            self.saveScript()

    def onSelectedScriptChanged(self, selected, _deselected):
        index = [i.row() for i in selected.indexes()]
        if index:
            current = index[0]
            if current >= len(self.libraryList):
                self.addNewScriptAction.trigger()
                return

            self.text.setDocument(self.documentForScript(current))
            self.currentScriptIndex = current

    def documentForScript(self, script=0):
        if not isinstance(script, Script):
            script = self.libraryList[script]
        if script not in self._cachedDocuments:
            doc = QTextDocument(self)
            doc.setDocumentLayout(QPlainTextDocumentLayout(doc))
            doc.setPlainText(script.script)
            doc.setDefaultFont(QFont(self.defaultFont))
            doc.highlighter = PythonSyntaxHighlighter(doc)
            doc.modificationChanged[bool].connect(self.onModificationChanged)
            doc.setModified(False)
            self._cachedDocuments[script] = doc
        return self._cachedDocuments[script]

    def commitChangesToLibrary(self, *_):
        index = self.selectedScriptIndex()
        if index is not None:
            self.libraryList[index].script = self.text.toPlainText()
            self.text.document().setModified(False)
            self.libraryList.emitDataChanged(index)

    def onModificationChanged(self, modified):
        index = self.selectedScriptIndex()
        if index is not None:
            self.libraryList[index].flags = Script.Modified if modified else 0
            self.libraryList.emitDataChanged(index)

    def restoreSaved(self):
        index = self.selectedScriptIndex()
        if index is not None:
            self.text.document().setPlainText(self.libraryList[index].script)
            self.text.document().setModified(False)

    def saveScript(self):
        index = self.selectedScriptIndex()
        if index is not None:
            script = self.libraryList[index]
            filename = script.filename
        else:
            filename = os.path.expanduser("~/")

        filename, _ = QFileDialog.getSaveFileName(
            self, 'Save Python Script',
            filename,
            'Python files (*.py)\nAll files(*.*)'
        )

        if filename:
            fn = ""
            head, tail = os.path.splitext(filename)
            if not tail:
                fn = head + ".py"
            else:
                fn = filename

            f = open(fn, 'w')
            f.write(self.text.toPlainText())
            f.close()

    def initial_locals_state(self):
        d = self.shared_namespaces.setdefault(self.signalManager, {}).copy()
        for name in self.signal_names:
            value = getattr(self, name)
            all_values = list(value.values())
            one_value = all_values[0] if len(all_values) == 1 else None
            d["in_" + name + "s"] = all_values
            d["in_" + name] = one_value
        return d

    def update_namespace(self, namespace):
        not_saved = reduce(set.union,
                           ({f"in_{name}s", f"in_{name}", f"out_{name}"}
                            for name in self.signal_names))
        self.shared_namespaces.setdefault(self.signalManager, {}).update(
            {name: value for name, value in namespace.items()
             if name not in not_saved})

    def commit(self):
        self.Error.clear()
        lcls = self.initial_locals_state()
        lcls["_script"] = str(self.text.toPlainText())
        self.console.updateLocals(lcls)
        self.console.write("\nRunning script:\n")
        self.console.push("exec(_script)")
        self.console.new_prompt(sys.ps1)
        self.update_namespace(self.console.locals)
        for signal in self.signal_names:
            out_var = self.console.locals.get("out_" + signal)
            signal_type = getattr(self.Outputs, signal).type
            if not isinstance(out_var, signal_type) and out_var is not None:
                self.Error.add_message(signal,
                                       "'{}' has to be an instance of '{}'.".
                                       format(signal, signal_type.__name__))
                getattr(self.Error, signal)()
                out_var = None
            getattr(self.Outputs, signal).send(out_var)

    def dragEnterEvent(self, event):  # pylint: disable=no-self-use
        urls = event.mimeData().urls()
        if urls:
            # try reading the file as text
            c = read_file_content(urls[0].toLocalFile(), limit=1000)
            if c is not None:
                event.acceptProposedAction()

    def dropEvent(self, event):
        """Handle file drops"""
        urls = event.mimeData().urls()
        if urls:
            self.text.pasteFile(urls[0])

    @classmethod
    def migrate_settings(cls, settings, version):
        if version is not None and version < 2:
            scripts = settings.pop("libraryListSource")  # type: List[Script]
            library = [dict(name=s.name, script=s.script, filename=s.filename)
                       for s in scripts]  # type: List[_ScriptData]
            settings["scriptLibrary"] = library


if __name__ == "__main__":  # pragma: no cover
    WidgetPreview(OWPythonScript).run()

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
[ISSUE]
**Title:** TypeError When Handling Signal ID in OWPythonScript Widget

**Description:**
Sending signals to the `OWPythonScript` widget results in a `TypeError` because the signal ID is incorrectly treated as a subscriptable object.

**Example:**
When a signal is sent with an integer ID, the widget attempts to access it as if it were a list or tuple.

```python
def test_inputs(self):
    for input_, data in (("Data", self.iris),
                         ("Learner", self.learner),
                         ("Classifier", self.model),
                         ("Object", "object")):
        self.send_signal(input_, data, 1)
```

**Expected Behavior:**
The widget should use the signal ID directly as an integer to track inputs without attempting to subscript it.

**Actual Behavior:**
A `TypeError` is raised because the widget tries to subscript the integer signal ID, leading to failures in multiple tests.

```
TypeError: 'int' object is not subscriptable
```

[/ISSUE]
{
    "TestOWPythonScript.test_dragEnterEvent_accepts_text": "PASSED",
    "TestOWPythonScript.test_dragEnterEvent_rejects_binary": "PASSED",
    "TestOWPythonScript.test_dropEvent_replaces_file": "PASSED",
    "TestOWPythonScript.test_image_export": "PASSED",
    "TestOWPythonScript.test_inputs": "PASSED",
    "TestOWPythonScript.test_local_variable": "PASSED",
    "TestOWPythonScript.test_migrate": "PASSED",
    "TestOWPythonScript.test_minimum_size": "PASSED",
    "TestOWPythonScript.test_msg_base_class": "PASSED",
    "TestOWPythonScript.test_multiple_signals": "PASSED",
    "TestOWPythonScript.test_outputs": "PASSED",
    "TestOWPythonScript.test_owns_errors": "PASSED",
    "TestOWPythonScript.test_read_file_content": "PASSED",
    "TestOWPythonScript.test_restore": "PASSED",
    "TestOWPythonScript.test_restore_from_library": "PASSED",
    "TestOWPythonScript.test_script_insert_mime_file": "PASSED",
    "TestOWPythonScript.test_script_insert_mime_text": "PASSED",
    "TestOWPythonScript.test_shared_namespaces": "PASSED",
    "TestOWPythonScript.test_store_current_script": "PASSED",
    "TestOWPythonScript.test_store_new_script": "PASSED",
    "TestOWPythonScript.test_wrong_outputs": "PASSED"
}
diff --git a/Orange/widgets/data/owpythonscript.py b/Orange/widgets/data/owpythonscript.py
index 2f9089f27..47b088792 100644
--- a/Orange/widgets/data/owpythonscript.py
+++ b/Orange/widgets/data/owpythonscript.py
@@ -590,7 +590,6 @@ class OWPythonScript(OWWidget):
         self.splitterState = bytes(self.splitCanvas.saveState())
 
     def handle_input(self, obj, sig_id, signal):
-        sig_id = sig_id[0]
         dic = getattr(self, signal)
         if obj is None:
             if sig_id in dic.keys():

{"Orange/widgets/data/owpythonscript.py": "import sys\nimport os\nimport code\nimport keyword\nimport itertools\nimport unicodedata\nimport weakref\nfrom functools import reduce\nfrom unittest.mock import patch\n\nfrom typing import Optional, List, TYPE_CHECKING\n\nfrom AnyQt.QtWidgets import (\n    QPlainTextEdit, QListView, QSizePolicy, QMenu, QSplitter, QLineEdit,\n    QAction, QToolButton, QFileDialog, QStyledItemDelegate,\n    QStyleOptionViewItem, QPlainTextDocumentLayout\n)\nfrom AnyQt.QtGui import (\n    QColor, QBrush, QPalette, QFont, QTextDocument,\n    QSyntaxHighlighter, QTextCharFormat, QTextCursor, QKeySequence,\n)\nfrom AnyQt.QtCore import Qt, QRegExp, QByteArray, QItemSelectionModel, QSize\n\nfrom Orange.data import Table\nfrom Orange.base import Learner, Model\nfrom Orange.util import interleave\nfrom Orange.widgets import gui\nfrom Orange.widgets.utils import itemmodels\nfrom Orange.widgets.settings import Setting\nfrom Orange.widgets.utils.widgetpreview import WidgetPreview\nfrom Orange.widgets.widget import OWWidget, Input, Output\n\nif TYPE_CHECKING:\n    from typing_extensions import TypedDict\n\n__all__ = [\"OWPythonScript\"]\n\n\ndef text_format(foreground=Qt.black, weight=QFont.Normal):\n    fmt = QTextCharFormat()\n    fmt.setForeground(QBrush(foreground))\n    fmt.setFontWeight(weight)\n    return fmt\n\n\ndef read_file_content(filename, limit=None):\n    try:\n        with open(filename, encoding=\"utf-8\", errors='strict') as f:\n            text = f.read(limit)\n            return text\n    except (OSError, UnicodeDecodeError):\n        return None\n\n\nclass PythonSyntaxHighlighter(QSyntaxHighlighter):\n    def __init__(self, parent=None):\n\n        self.keywordFormat = text_format(Qt.blue, QFont.Bold)\n        self.stringFormat = text_format(Qt.darkGreen)\n        self.defFormat = text_format(Qt.black, QFont.Bold)\n        self.commentFormat = text_format(Qt.lightGray)\n        self.decoratorFormat = text_format(Qt.darkGray)\n\n        self.keywords = list(keyword.kwlist)\n\n        self.rules = [(QRegExp(r\"\\b%s\\b\" % kwd), self.keywordFormat)\n                      for kwd in self.keywords] + \\\n                     [(QRegExp(r\"\\bdef\\s+([A-Za-z_]+[A-Za-z0-9_]+)\\s*\\(\"),\n                       self.defFormat),\n                      (QRegExp(r\"\\bclass\\s+([A-Za-z_]+[A-Za-z0-9_]+)\\s*\\(\"),\n                       self.defFormat),\n                      (QRegExp(r\"'.*'\"), self.stringFormat),\n                      (QRegExp(r'\".*\"'), self.stringFormat),\n                      (QRegExp(r\"#.*\"), self.commentFormat),\n                      (QRegExp(r\"@[A-Za-z_]+[A-Za-z0-9_]+\"),\n                       self.decoratorFormat)]\n\n        self.multilineStart = QRegExp(r\"(''')|\" + r'(\"\"\")')\n        self.multilineEnd = QRegExp(r\"(''')|\" + r'(\"\"\")')\n\n        super().__init__(parent)\n\n    def highlightBlock(self, text):\n        for pattern, fmt in self.rules:\n            exp = QRegExp(pattern)\n            index = exp.indexIn(text)\n            while index >= 0:\n                length = exp.matchedLength()\n                if exp.captureCount() > 0:\n                    self.setFormat(exp.pos(1), len(str(exp.cap(1))), fmt)\n                else:\n                    self.setFormat(exp.pos(0), len(str(exp.cap(0))), fmt)\n                index = exp.indexIn(text, index + length)\n\n        # Multi line strings\n        start = self.multilineStart\n        end = self.multilineEnd\n\n        self.setCurrentBlockState(0)\n        startIndex, skip = 0, 0\n        if self.previousBlockState() != 1:\n            startIndex, skip = start.indexIn(text), 3\n        while startIndex >= 0:\n            endIndex = end.indexIn(text, startIndex + skip)\n            if endIndex == -1:\n                self.setCurrentBlockState(1)\n                commentLen = len(text) - startIndex\n            else:\n                commentLen = endIndex - startIndex + 3\n            self.setFormat(startIndex, commentLen, self.stringFormat)\n            startIndex, skip = (start.indexIn(text,\n                                              startIndex + commentLen + 3),\n                                3)\n\n\nclass PythonScriptEditor(QPlainTextEdit):\n    INDENT = 4\n\n    def __init__(self, widget):\n        super().__init__()\n        self.widget = widget\n\n    def lastLine(self):\n        text = str(self.toPlainText())\n        pos = self.textCursor().position()\n        index = text.rfind(\"\\n\", 0, pos)\n        text = text[index: pos].lstrip(\"\\n\")\n        return text\n\n    def keyPressEvent(self, event):\n        if event.key() == Qt.Key_Return:\n            if event.modifiers() & (\n                    Qt.ShiftModifier | Qt.ControlModifier | Qt.MetaModifier):\n                self.widget.commit()\n                return\n            text = self.lastLine()\n            indent = len(text) - len(text.lstrip())\n            if text.strip() == \"pass\" or text.strip().startswith(\"return \"):\n                indent = max(0, indent - self.INDENT)\n            elif text.strip().endswith(\":\"):\n                indent += self.INDENT\n            super().keyPressEvent(event)\n            self.insertPlainText(\" \" * indent)\n        elif event.key() == Qt.Key_Tab:\n            self.insertPlainText(\" \" * self.INDENT)\n        elif event.key() == Qt.Key_Backspace:\n            text = self.lastLine()\n            if text and not text.strip():\n                cursor = self.textCursor()\n                for _ in range(min(self.INDENT, len(text))):\n                    cursor.deletePreviousChar()\n            else:\n                super().keyPressEvent(event)\n\n        else:\n            super().keyPressEvent(event)\n\n    def insertFromMimeData(self, source):\n        \"\"\"\n        Reimplemented from QPlainTextEdit.insertFromMimeData.\n        \"\"\"\n        urls = source.urls()\n        if urls:\n            self.pasteFile(urls[0])\n        else:\n            super().insertFromMimeData(source)\n\n    def pasteFile(self, url):\n        new = read_file_content(url.toLocalFile())\n        if new:\n            # inserting text like this allows undo\n            cursor = QTextCursor(self.document())\n            cursor.select(QTextCursor.Document)\n            cursor.insertText(new)\n\n\nclass PythonConsole(QPlainTextEdit, code.InteractiveConsole):\n    # `locals` is reasonably used as argument name\n    # pylint: disable=redefined-builtin\n    def __init__(self, locals=None, parent=None):\n        QPlainTextEdit.__init__(self, parent)\n        code.InteractiveConsole.__init__(self, locals)\n        self.newPromptPos = 0\n        self.history, self.historyInd = [\"\"], 0\n        self.loop = self.interact()\n        next(self.loop)\n\n    def setLocals(self, locals):\n        self.locals = locals\n\n    def updateLocals(self, locals):\n        self.locals.update(locals)\n\n    def interact(self, banner=None, _=None):\n        try:\n            sys.ps1\n        except AttributeError:\n            sys.ps1 = \">>> \"\n        try:\n            sys.ps2\n        except AttributeError:\n            sys.ps2 = \"... \"\n        cprt = ('Type \"help\", \"copyright\", \"credits\" or \"license\" '\n                'for more information.')\n        if banner is None:\n            self.write(\"Python %s on %s\\n%s\\n(%s)\\n\" %\n                       (sys.version, sys.platform, cprt,\n                        self.__class__.__name__))\n        else:\n            self.write(\"%s\\n\" % str(banner))\n        more = 0\n        while 1:\n            try:\n                if more:\n                    prompt = sys.ps2\n                else:\n                    prompt = sys.ps1\n                self.new_prompt(prompt)\n                yield\n                try:\n                    line = self.raw_input(prompt)\n                except EOFError:\n                    self.write(\"\\n\")\n                    break\n                else:\n                    more = self.push(line)\n            except KeyboardInterrupt:\n                self.write(\"\\nKeyboardInterrupt\\n\")\n                self.resetbuffer()\n                more = 0\n\n    def raw_input(self, prompt=\"\"):\n        input_str = str(self.document().lastBlock().previous().text())\n        return input_str[len(prompt):]\n\n    def new_prompt(self, prompt):\n        self.write(prompt)\n        self.newPromptPos = self.textCursor().position()\n        self.repaint()\n\n    def write(self, data):\n        cursor = QTextCursor(self.document())\n        cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor)\n        cursor.insertText(data)\n        self.setTextCursor(cursor)\n        self.ensureCursorVisible()\n\n    def writelines(self, lines):\n        for line in lines:\n            self.write(line)\n\n    def flush(self):\n        pass\n\n    def push(self, line):\n        if self.history[0] != line:\n            self.history.insert(0, line)\n        self.historyInd = 0\n\n        # prevent console errors to trigger error reporting & patch stdout, stderr\n        with patch('sys.excepthook', sys.__excepthook__),\\\n             patch('sys.stdout', self),\\\n             patch('sys.stderr', self):\n            return code.InteractiveConsole.push(self, line)\n\n    def setLine(self, line):\n        cursor = QTextCursor(self.document())\n        cursor.movePosition(QTextCursor.End)\n        cursor.setPosition(self.newPromptPos, QTextCursor.KeepAnchor)\n        cursor.removeSelectedText()\n        cursor.insertText(line)\n        self.setTextCursor(cursor)\n\n    def keyPressEvent(self, event):\n        if event.key() == Qt.Key_Return:\n            self.write(\"\\n\")\n            next(self.loop)\n        elif event.key() == Qt.Key_Up:\n            self.historyUp()\n        elif event.key() == Qt.Key_Down:\n            self.historyDown()\n        elif event.key() == Qt.Key_Tab:\n            self.complete()\n        elif event.key() in [Qt.Key_Left, Qt.Key_Backspace]:\n            if self.textCursor().position() > self.newPromptPos:\n                QPlainTextEdit.keyPressEvent(self, event)\n        else:\n            QPlainTextEdit.keyPressEvent(self, event)\n\n    def historyUp(self):\n        self.setLine(self.history[self.historyInd])\n        self.historyInd = min(self.historyInd + 1, len(self.history) - 1)\n\n    def historyDown(self):\n        self.setLine(self.history[self.historyInd])\n        self.historyInd = max(self.historyInd - 1, 0)\n\n    def complete(self):\n        pass\n\n    def _moveCursorToInputLine(self):\n        \"\"\"\n        Move the cursor to the input line if not already there. If the cursor\n        if already in the input line (at position greater or equal to\n        `newPromptPos`) it is left unchanged, otherwise it is moved at the\n        end.\n\n        \"\"\"\n        cursor = self.textCursor()\n        pos = cursor.position()\n        if pos < self.newPromptPos:\n            cursor.movePosition(QTextCursor.End)\n            self.setTextCursor(cursor)\n\n    def pasteCode(self, source):\n        \"\"\"\n        Paste source code into the console.\n        \"\"\"\n        self._moveCursorToInputLine()\n\n        for line in interleave(source.splitlines(), itertools.repeat(\"\\n\")):\n            if line != \"\\n\":\n                self.insertPlainText(line)\n            else:\n                self.write(\"\\n\")\n                next(self.loop)\n\n    def insertFromMimeData(self, source):\n        \"\"\"\n        Reimplemented from QPlainTextEdit.insertFromMimeData.\n        \"\"\"\n        if source.hasText():\n            self.pasteCode(str(source.text()))\n            return\n\n\nclass Script:\n    Modified = 1\n    MissingFromFilesystem = 2\n\n    def __init__(self, name, script, flags=0, filename=None):\n        self.name = name\n        self.script = script\n        self.flags = flags\n        self.filename = filename\n\n    def asdict(self) -> '_ScriptData':\n        return dict(name=self.name, script=self.script, filename=self.filename)\n\n    @classmethod\n    def fromdict(cls, state: '_ScriptData') -> 'Script':\n        return Script(state[\"name\"], state[\"script\"], filename=state[\"filename\"])\n\n\nclass ScriptItemDelegate(QStyledItemDelegate):\n    # pylint: disable=no-self-use\n    def displayText(self, script, _locale):\n        if script.flags & Script.Modified:\n            return \"*\" + script.name\n        else:\n            return script.name\n\n    def paint(self, painter, option, index):\n        script = index.data(Qt.DisplayRole)\n\n        if script.flags & Script.Modified:\n            option = QStyleOptionViewItem(option)\n            option.palette.setColor(QPalette.Text, QColor(Qt.red))\n            option.palette.setColor(QPalette.Highlight, QColor(Qt.darkRed))\n        super().paint(painter, option, index)\n\n    def createEditor(self, parent, _option, _index):\n        return QLineEdit(parent)\n\n    def setEditorData(self, editor, index):\n        script = index.data(Qt.DisplayRole)\n        editor.setText(script.name)\n\n    def setModelData(self, editor, model, index):\n        model[index.row()].name = str(editor.text())\n\n\ndef select_row(view, row):\n    \"\"\"\n    Select a `row` in an item view\n    \"\"\"\n    selmodel = view.selectionModel()\n    selmodel.select(view.model().index(row, 0),\n                    QItemSelectionModel.ClearAndSelect)\n\n\nif TYPE_CHECKING:\n    # pylint: disable=used-before-assignment\n    _ScriptData = TypedDict(\"_ScriptData\", {\n        \"name\": str, \"script\": str, \"filename\": Optional[str]\n    })\n\n\nclass OWPythonScript(OWWidget):\n    name = \"Python Script\"\n    description = \"Write a Python script and run it on input data or models.\"\n    icon = \"icons/PythonScript.svg\"\n    priority = 3150\n    keywords = [\"file\", \"program\"]\n\n    class Inputs:\n        data = Input(\"Data\", Table, replaces=[\"in_data\"],\n                     default=True, multiple=True)\n        learner = Input(\"Learner\", Learner, replaces=[\"in_learner\"],\n                        default=True, multiple=True)\n        classifier = Input(\"Classifier\", Model, replaces=[\"in_classifier\"],\n                           default=True, multiple=True)\n        object = Input(\"Object\", object, replaces=[\"in_object\"],\n                       default=False, multiple=True)\n\n    class Outputs:\n        data = Output(\"Data\", Table, replaces=[\"out_data\"])\n        learner = Output(\"Learner\", Learner, replaces=[\"out_learner\"])\n        classifier = Output(\"Classifier\", Model, replaces=[\"out_classifier\"])\n        object = Output(\"Object\", object, replaces=[\"out_object\"])\n\n    signal_names = (\"data\", \"learner\", \"classifier\", \"object\")\n\n    settings_version = 2\n    scriptLibrary: 'List[_ScriptData]' = Setting([{\n        \"name\": \"Hello world\",\n        \"script\": \"print('Hello world')\\n\",\n        \"filename\": None\n    }])\n    currentScriptIndex = Setting(0)\n    scriptText: Optional[str] = Setting(None, schema_only=True)\n    splitterState: Optional[bytes] = Setting(None)\n\n    # Widgets in the same schema share namespace through a dictionary whose\n    # key is self.signalManager. ales-erjavec expressed concern (and I fully\n    # agree!) about widget being aware of the outside world. I am leaving this\n    # anyway. If this causes any problems in the future, replace this with\n    # shared_namespaces = {} and thus use a common namespace for all instances\n    # of # PythonScript even if they are in different schemata.\n    shared_namespaces = weakref.WeakKeyDictionary()\n\n    class Error(OWWidget.Error):\n        pass\n\n    def __init__(self):\n        super().__init__()\n        self.libraryListSource = []\n\n        for name in self.signal_names:\n            setattr(self, name, {})\n\n        self._cachedDocuments = {}\n\n        self.infoBox = gui.vBox(self.controlArea, 'Info')\n        gui.label(\n            self.infoBox, self,\n            \"<p>Execute python script.</p><p>Input variables:<ul><li> \" +\n            \"<li>\".join(map(\"in_{0}, in_{0}s\".format, self.signal_names)) +\n            \"</ul></p><p>Output variables:<ul><li>\" +\n            \"<li>\".join(map(\"out_{0}\".format, self.signal_names)) +\n            \"</ul></p>\"\n        )\n\n        self.libraryList = itemmodels.PyListModel(\n            [], self,\n            flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)\n\n        self.libraryList.wrap(self.libraryListSource)\n\n        self.controlBox = gui.vBox(self.controlArea, 'Library')\n        self.controlBox.layout().setSpacing(1)\n\n        self.libraryView = QListView(\n            editTriggers=QListView.DoubleClicked |\n            QListView.EditKeyPressed,\n            sizePolicy=QSizePolicy(QSizePolicy.Ignored,\n                                   QSizePolicy.Preferred)\n        )\n        self.libraryView.setItemDelegate(ScriptItemDelegate(self))\n        self.libraryView.setModel(self.libraryList)\n\n        self.libraryView.selectionModel().selectionChanged.connect(\n            self.onSelectedScriptChanged\n        )\n        self.controlBox.layout().addWidget(self.libraryView)\n\n        w = itemmodels.ModelActionsWidget()\n\n        self.addNewScriptAction = action = QAction(\"+\", self)\n        action.setToolTip(\"Add a new script to the library\")\n        action.triggered.connect(self.onAddScript)\n        w.addAction(action)\n\n        action = QAction(unicodedata.lookup(\"MINUS SIGN\"), self)\n        action.setToolTip(\"Remove script from library\")\n        action.triggered.connect(self.onRemoveScript)\n        w.addAction(action)\n\n        action = QAction(\"Update\", self)\n        action.setToolTip(\"Save changes in the editor to library\")\n        action.setShortcut(QKeySequence(QKeySequence.Save))\n        action.triggered.connect(self.commitChangesToLibrary)\n        w.addAction(action)\n\n        action = QAction(\"More\", self, toolTip=\"More actions\")\n\n        new_from_file = QAction(\"Import Script from File\", self)\n        save_to_file = QAction(\"Save Selected Script to File\", self)\n        restore_saved = QAction(\"Undo Changes to Selected Script\", self)\n        save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))\n\n        new_from_file.triggered.connect(self.onAddScriptFromFile)\n        save_to_file.triggered.connect(self.saveScript)\n        restore_saved.triggered.connect(self.restoreSaved)\n\n        menu = QMenu(w)\n        menu.addAction(new_from_file)\n        menu.addAction(save_to_file)\n        menu.addAction(restore_saved)\n        action.setMenu(menu)\n        button = w.addAction(action)\n        button.setPopupMode(QToolButton.InstantPopup)\n\n        w.layout().setSpacing(1)\n\n        self.controlBox.layout().addWidget(w)\n\n        self.execute_button = gui.button(self.controlArea, self, 'Run', callback=self.commit)\n\n        run = QAction(\"Run script\", self, triggered=self.commit,\n                      shortcut=QKeySequence(Qt.ControlModifier | Qt.Key_R))\n        self.addAction(run)\n\n        self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)\n        self.mainArea.layout().addWidget(self.splitCanvas)\n\n        self.defaultFont = defaultFont = \\\n            \"Monaco\" if sys.platform == \"darwin\" else \"Courier\"\n\n        self.textBox = gui.vBox(self, 'Python Script')\n        self.splitCanvas.addWidget(self.textBox)\n        self.text = PythonScriptEditor(self)\n        self.textBox.layout().addWidget(self.text)\n\n        self.textBox.setAlignment(Qt.AlignVCenter)\n        self.text.setTabStopWidth(4)\n\n        self.text.modificationChanged[bool].connect(self.onModificationChanged)\n\n        self.saveAction = action = QAction(\"&Save\", self.text)\n        action.setToolTip(\"Save script to file\")\n        action.setShortcut(QKeySequence(QKeySequence.Save))\n        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)\n        action.triggered.connect(self.saveScript)\n\n        self.consoleBox = gui.vBox(self, 'Console')\n        self.splitCanvas.addWidget(self.consoleBox)\n        self.console = PythonConsole({}, self)\n        self.consoleBox.layout().addWidget(self.console)\n        self.console.document().setDefaultFont(QFont(defaultFont))\n        self.consoleBox.setAlignment(Qt.AlignBottom)\n        self.console.setTabStopWidth(4)\n        self.splitCanvas.setSizes([2, 1])\n        self.setAcceptDrops(True)\n        self.controlArea.layout().addStretch(10)\n\n        self._restoreState()\n        self.settingsAboutToBePacked.connect(self._saveState)\n\n    def sizeHint(self) -> QSize:\n        return super().sizeHint().expandedTo(QSize(800, 600))\n\n    def _restoreState(self):\n        self.libraryListSource = [Script.fromdict(s) for s in self.scriptLibrary]\n        self.libraryList.wrap(self.libraryListSource)\n        select_row(self.libraryView, self.currentScriptIndex)\n\n        if self.scriptText is not None:\n            current = self.text.toPlainText()\n            # do not mark scripts as modified\n            if self.scriptText != current:\n                self.text.document().setPlainText(self.scriptText)\n\n        if self.splitterState is not None:\n            self.splitCanvas.restoreState(QByteArray(self.splitterState))\n\n    def _saveState(self):\n        self.scriptLibrary = [s.asdict() for s in self.libraryListSource]\n        self.scriptText = self.text.toPlainText()\n        self.splitterState = bytes(self.splitCanvas.saveState())\n\n    def handle_input(self, obj, sig_id, signal):\n        sig_id = sig_id[0]\n        dic = getattr(self, signal)\n        if obj is None:\n            if sig_id in dic.keys():\n                del dic[sig_id]\n        else:\n            dic[sig_id] = obj\n\n    @Inputs.data\n    def set_data(self, data, sig_id):\n        self.handle_input(data, sig_id, \"data\")\n\n    @Inputs.learner\n    def set_learner(self, data, sig_id):\n        self.handle_input(data, sig_id, \"learner\")\n\n    @Inputs.classifier\n    def set_classifier(self, data, sig_id):\n        self.handle_input(data, sig_id, \"classifier\")\n\n    @Inputs.object\n    def set_object(self, data, sig_id):\n        self.handle_input(data, sig_id, \"object\")\n\n    def handleNewSignals(self):\n        self.commit()\n\n    def selectedScriptIndex(self):\n        rows = self.libraryView.selectionModel().selectedRows()\n        if rows:\n            return [i.row() for i in rows][0]\n        else:\n            return None\n\n    def setSelectedScript(self, index):\n        select_row(self.libraryView, index)\n\n    def onAddScript(self, *_):\n        self.libraryList.append(Script(\"New script\", self.text.toPlainText(), 0))\n        self.setSelectedScript(len(self.libraryList) - 1)\n\n    def onAddScriptFromFile(self, *_):\n        filename, _ = QFileDialog.getOpenFileName(\n            self, 'Open Python Script',\n            os.path.expanduser(\"~/\"),\n            'Python files (*.py)\\nAll files(*.*)'\n        )\n        if filename:\n            name = os.path.basename(filename)\n            # TODO: use `tokenize.detect_encoding`\n            with open(filename, encoding=\"utf-8\") as f:\n                contents = f.read()\n            self.libraryList.append(Script(name, contents, 0, filename))\n            self.setSelectedScript(len(self.libraryList) - 1)\n\n    def onRemoveScript(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            del self.libraryList[index]\n            select_row(self.libraryView, max(index - 1, 0))\n\n    def onSaveScriptToFile(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.saveScript()\n\n    def onSelectedScriptChanged(self, selected, _deselected):\n        index = [i.row() for i in selected.indexes()]\n        if index:\n            current = index[0]\n            if current >= len(self.libraryList):\n                self.addNewScriptAction.trigger()\n                return\n\n            self.text.setDocument(self.documentForScript(current))\n            self.currentScriptIndex = current\n\n    def documentForScript(self, script=0):\n        if not isinstance(script, Script):\n            script = self.libraryList[script]\n        if script not in self._cachedDocuments:\n            doc = QTextDocument(self)\n            doc.setDocumentLayout(QPlainTextDocumentLayout(doc))\n            doc.setPlainText(script.script)\n            doc.setDefaultFont(QFont(self.defaultFont))\n            doc.highlighter = PythonSyntaxHighlighter(doc)\n            doc.modificationChanged[bool].connect(self.onModificationChanged)\n            doc.setModified(False)\n            self._cachedDocuments[script] = doc\n        return self._cachedDocuments[script]\n\n    def commitChangesToLibrary(self, *_):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.libraryList[index].script = self.text.toPlainText()\n            self.text.document().setModified(False)\n            self.libraryList.emitDataChanged(index)\n\n    def onModificationChanged(self, modified):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.libraryList[index].flags = Script.Modified if modified else 0\n            self.libraryList.emitDataChanged(index)\n\n    def restoreSaved(self):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            self.text.document().setPlainText(self.libraryList[index].script)\n            self.text.document().setModified(False)\n\n    def saveScript(self):\n        index = self.selectedScriptIndex()\n        if index is not None:\n            script = self.libraryList[index]\n            filename = script.filename\n        else:\n            filename = os.path.expanduser(\"~/\")\n\n        filename, _ = QFileDialog.getSaveFileName(\n            self, 'Save Python Script',\n            filename,\n            'Python files (*.py)\\nAll files(*.*)'\n        )\n\n        if filename:\n            fn = \"\"\n            head, tail = os.path.splitext(filename)\n            if not tail:\n                fn = head + \".py\"\n            else:\n                fn = filename\n\n            f = open(fn, 'w')\n            f.write(self.text.toPlainText())\n            f.close()\n\n    def initial_locals_state(self):\n        d = self.shared_namespaces.setdefault(self.signalManager, {}).copy()\n        for name in self.signal_names:\n            value = getattr(self, name)\n            all_values = list(value.values())\n            one_value = all_values[0] if len(all_values) == 1 else None\n            d[\"in_\" + name + \"s\"] = all_values\n            d[\"in_\" + name] = one_value\n        return d\n\n    def update_namespace(self, namespace):\n        not_saved = reduce(set.union,\n                           ({f\"in_{name}s\", f\"in_{name}\", f\"out_{name}\"}\n                            for name in self.signal_names))\n        self.shared_namespaces.setdefault(self.signalManager, {}).update(\n            {name: value for name, value in namespace.items()\n             if name not in not_saved})\n\n    def commit(self):\n        self.Error.clear()\n        lcls = self.initial_locals_state()\n        lcls[\"_script\"] = str(self.text.toPlainText())\n        self.console.updateLocals(lcls)\n        self.console.write(\"\\nRunning script:\\n\")\n        self.console.push(\"exec(_script)\")\n        self.console.new_prompt(sys.ps1)\n        self.update_namespace(self.console.locals)\n        for signal in self.signal_names:\n            out_var = self.console.locals.get(\"out_\" + signal)\n            signal_type = getattr(self.Outputs, signal).type\n            if not isinstance(out_var, signal_type) and out_var is not None:\n                self.Error.add_message(signal,\n                                       \"'{}' has to be an instance of '{}'.\".\n                                       format(signal, signal_type.__name__))\n                getattr(self.Error, signal)()\n                out_var = None\n            getattr(self.Outputs, signal).send(out_var)\n\n    def dragEnterEvent(self, event):  # pylint: disable=no-self-use\n        urls = event.mimeData().urls()\n        if urls:\n            # try reading the file as text\n            c = read_file_content(urls[0].toLocalFile(), limit=1000)\n            if c is not None:\n                event.acceptProposedAction()\n\n    def dropEvent(self, event):\n        \"\"\"Handle file drops\"\"\"\n        urls = event.mimeData().urls()\n        if urls:\n            self.text.pasteFile(urls[0])\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if version is not None and version < 2:\n            scripts = settings.pop(\"libraryListSource\")  # type: List[Script]\n            library = [dict(name=s.name, script=s.script, filename=s.filename)\n                       for s in scripts]  # type: List[_ScriptData]\n            settings[\"scriptLibrary\"] = library\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    WidgetPreview(OWPythonScript).run()\n"}
A user will ask you to solve a task. You should first draft your thinking process (inner monologue). Then, generate the solution.

Your response format must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct solution.
</think>
<solution>
Final solution presented to the user.
</solution>
system
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** TypeError When Handling Signal ID in OWPythonScript Widget

**Description:**
Sending signals to the `OWPythonScript` widget results in a `TypeError` because the signal ID is incorrectly treated as a subscriptable object.

**Example:**
When a signal is sent with an integer ID, the widget attempts to access it as if it were a list or tuple.

```python
def test_inputs(self):
    for input_, data in (("Data", self.iris),
                         ("Learner", self.learner),
                         ("Classifier", self.model),
                         ("Object", "object")):
        self.send_signal(input_, data, 1)
```

**Expected Behavior:**
The widget should use the signal ID directly as an integer to track inputs without attempting to subscript it.

**Actual Behavior:**
A `TypeError` is raised because the widget tries to subscript the integer signal ID, leading to failures in multiple tests.

```
TypeError: 'int' object is not subscriptable
```

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### Orange/widgets/data/owpythonscript.py
import sys
import os
import code
import keyword
import itertools
import unicodedata
import weakref
from functools import reduce
from unittest.mock import patch

from typing import Optional, List, TYPE_CHECKING

from AnyQt.QtWidgets import (
    QPlainTextEdit, QListView, QSizePolicy, QMenu, QSplitter, QLineEdit,
    QAction, QToolButton, QFileDialog, QStyledItemDelegate,
    QStyleOptionViewItem, QPlainTextDocumentLayout
)
from AnyQt.QtGui import (
    QColor, QBrush, QPalette, QFont, QTextDocument,
    QSyntaxHighlighter, QTextCharFormat, QTextCursor, QKeySequence,
)
from AnyQt.QtCore import Qt, QRegExp, QByteArray, QItemSelectionModel, QSize

from Orange.data import Table
from Orange.base import Learner, Model
from Orange.util import interleave
from Orange.widgets import gui
from Orange.widgets.utils import itemmodels
from Orange.widgets.settings import Setting
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.widget import OWWidget, Input, Output

if TYPE_CHECKING:
    from typing_extensions import TypedDict

__all__ = ["OWPythonScript"]


def text_format(foreground=Qt.black, weight=QFont.Normal):
    fmt = QTextCharFormat()
    fmt.setForeground(QBrush(foreground))
    fmt.setFontWeight(weight)
    return fmt


def read_file_content(filename, limit=None):
    try:
        with open(filename, encoding="utf-8", errors='strict') as f:
            text = f.read(limit)
            return text
    except (OSError, UnicodeDecodeError):
        return None


class PythonSyntaxHighlighter(QSyntaxHighlighter):
    def __init__(self, parent=None):

        self.keywordFormat = text_format(Qt.blue, QFont.Bold)
        self.stringFormat = text_format(Qt.darkGreen)
        self.defFormat = text_format(Qt.black, QFont.Bold)
        self.commentFormat = text_format(Qt.lightGray)
        self.decoratorFormat = text_format(Qt.darkGray)

        self.keywords = list(keyword.kwlist)

        self.rules = [(QRegExp(r"\b%s\b" % kwd), self.keywordFormat)
                      for kwd in self.keywords] + \
                     [(QRegExp(r"\bdef\s+([A-Za-z_]+[A-Za-z0-9_]+)\s*\("),
                       self.defFormat),
                      (QRegExp(r"\bclass\s+([A-Za-z_]+[A-Za-z0-9_]+)\s*\("),
                       self.defFormat),
                      (QRegExp(r"'.*'"), self.stringFormat),
                      (QRegExp(r'".*"'), self.stringFormat),
                      (QRegExp(r"#.*"), self.commentFormat),
                      (QRegExp(r"@[A-Za-z_]+[A-Za-z0-9_]+"),
                       self.decoratorFormat)]

        self.multilineStart = QRegExp(r"(''')|" + r'(""")')
        self.multilineEnd = QRegExp(r"(''')|" + r'(""")')

        super().__init__(parent)

    def highlightBlock(self, text):
        for pattern, fmt in self.rules:
            exp = QRegExp(pattern)
            index = exp.indexIn(text)
            while index >= 0:
                length = exp.matchedLength()
                if exp.captureCount() > 0:
                    self.setFormat(exp.pos(1), len(str(exp.cap(1))), fmt)
                else:
                    self.setFormat(exp.pos(0), len(str(exp.cap(0))), fmt)
                index = exp.indexIn(text, index + length)

        # Multi line strings
        start = self.multilineStart
        end = self.multilineEnd

        self.setCurrentBlockState(0)
        startIndex, skip = 0, 0
        if self.previousBlockState() != 1:
            startIndex, skip = start.indexIn(text), 3
        while startIndex >= 0:
            endIndex = end.indexIn(text, startIndex + skip)
            if endIndex == -1:
                self.setCurrentBlockState(1)
                commentLen = len(text) - startIndex
            else:
                commentLen = endIndex - startIndex + 3
            self.setFormat(startIndex, commentLen, self.stringFormat)
            startIndex, skip = (start.indexIn(text,
                                              startIndex + commentLen + 3),
                                3)


class PythonScriptEditor(QPlainTextEdit):
    INDENT = 4

    def __init__(self, widget):
        super().__init__()
        self.widget = widget

    def lastLine(self):
        text = str(self.toPlainText())
        pos = self.textCursor().position()
        index = text.rfind("\n", 0, pos)
        text = text[index: pos].lstrip("\n")
        return text

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Return:
            if event.modifiers() & (
                    Qt.ShiftModifier | Qt.ControlModifier | Qt.MetaModifier):
                self.widget.commit()
                return
            text = self.lastLine()
            indent = len(text) - len(text.lstrip())
            if text.strip() == "pass" or text.strip().startswith("return "):
                indent = max(0, indent - self.INDENT)
            elif text.strip().endswith(":"):
                indent += self.INDENT
            super().keyPressEvent(event)
            self.insertPlainText(" " * indent)
        elif event.key() == Qt.Key_Tab:
            self.insertPlainText(" " * self.INDENT)
        elif event.key() == Qt.Key_Backspace:
            text = self.lastLine()
            if text and not text.strip():
                cursor = self.textCursor()
                for _ in range(min(self.INDENT, len(text))):
                    cursor.deletePreviousChar()
            else:
                super().keyPressEvent(event)

        else:
            super().keyPressEvent(event)

    def insertFromMimeData(self, source):
        """
        Reimplemented from QPlainTextEdit.insertFromMimeData.
        """
        urls = source.urls()
        if urls:
            self.pasteFile(urls[0])
        else:
            super().insertFromMimeData(source)

    def pasteFile(self, url):
        new = read_file_content(url.toLocalFile())
        if new:
            # inserting text like this allows undo
            cursor = QTextCursor(self.document())
            cursor.select(QTextCursor.Document)
            cursor.insertText(new)


class PythonConsole(QPlainTextEdit, code.InteractiveConsole):
    # `locals` is reasonably used as argument name
    # pylint: disable=redefined-builtin
    def __init__(self, locals=None, parent=None):
        QPlainTextEdit.__init__(self, parent)
        code.InteractiveConsole.__init__(self, locals)
        self.newPromptPos = 0
        self.history, self.historyInd = [""], 0
        self.loop = self.interact()
        next(self.loop)

    def setLocals(self, locals):
        self.locals = locals

    def updateLocals(self, locals):
        self.locals.update(locals)

    def interact(self, banner=None, _=None):
        try:
            sys.ps1
        except AttributeError:
            sys.ps1 = ">>> "
        try:
            sys.ps2
        except AttributeError:
            sys.ps2 = "... "
        cprt = ('Type "help", "copyright", "credits" or "license" '
                'for more information.')
        if banner is None:
            self.write("Python %s on %s\n%s\n(%s)\n" %
                       (sys.version, sys.platform, cprt,
                        self.__class__.__name__))
        else:
            self.write("%s\n" % str(banner))
        more = 0
        while 1:
            try:
                if more:
                    prompt = sys.ps2
                else:
                    prompt = sys.ps1
                self.new_prompt(prompt)
                yield
                try:
                    line = self.raw_input(prompt)
                except EOFError:
                    self.write("\n")
                    break
                else:
                    more = self.push(line)
            except KeyboardInterrupt:
                self.write("\nKeyboardInterrupt\n")
                self.resetbuffer()
                more = 0

    def raw_input(self, prompt=""):
        input_str = str(self.document().lastBlock().previous().text())
        return input_str[len(prompt):]

    def new_prompt(self, prompt):
        self.write(prompt)
        self.newPromptPos = self.textCursor().position()
        self.repaint()

    def write(self, data):
        cursor = QTextCursor(self.document())
        cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor)
        cursor.insertText(data)
        self.setTextCursor(cursor)
        self.ensureCursorVisible()

    def writelines(self, lines):
        for line in lines:
            self.write(line)

    def flush(self):
        pass

    def push(self, line):
        if self.history[0] != line:
            self.history.insert(0, line)
        self.historyInd = 0

        # prevent console errors to trigger error reporting & patch stdout, stderr
        with patch('sys.excepthook', sys.__excepthook__),\
             patch('sys.stdout', self),\
             patch('sys.stderr', self):
            return code.InteractiveConsole.push(self, line)

    def setLine(self, line):
        cursor = QTextCursor(self.document())
        cursor.movePosition(QTextCursor.End)
        cursor.setPosition(self.newPromptPos, QTextCursor.KeepAnchor)
        cursor.removeSelectedText()
        cursor.insertText(line)
        self.setTextCursor(cursor)

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Return:
            self.write("\n")
            next(self.loop)
        elif event.key() == Qt.Key_Up:
            self.historyUp()
        elif event.key() == Qt.Key_Down:
            self.historyDown()
        elif event.key() == Qt.Key_Tab:
            self.complete()
        elif event.key() in [Qt.Key_Left, Qt.Key_Backspace]:
            if self.textCursor().position() > self.newPromptPos:
                QPlainTextEdit.keyPressEvent(self, event)
        else:
            QPlainTextEdit.keyPressEvent(self, event)

    def historyUp(self):
        self.setLine(self.history[self.historyInd])
        self.historyInd = min(self.historyInd + 1, len(self.history) - 1)

    def historyDown(self):
        self.setLine(self.history[self.historyInd])
        self.historyInd = max(self.historyInd - 1, 0)

    def complete(self):
        pass

    def _moveCursorToInputLine(self):
        """
        Move the cursor to the input line if not already there. If the cursor
        if already in the input line (at position greater or equal to
        `newPromptPos`) it is left unchanged, otherwise it is moved at the
        end.

        """
        cursor = self.textCursor()
        pos = cursor.position()
        if pos < self.newPromptPos:
            cursor.movePosition(QTextCursor.End)
            self.setTextCursor(cursor)

    def pasteCode(self, source):
        """
        Paste source code into the console.
        """
        self._moveCursorToInputLine()

        for line in interleave(source.splitlines(), itertools.repeat("\n")):
            if line != "\n":
                self.insertPlainText(line)
            else:
                self.write("\n")
                next(self.loop)

    def insertFromMimeData(self, source):
        """
        Reimplemented from QPlainTextEdit.insertFromMimeData.
        """
        if source.hasText():
            self.pasteCode(str(source.text()))
            return


class Script:
    Modified = 1
    MissingFromFilesystem = 2

    def __init__(self, name, script, flags=0, filename=None):
        self.name = name
        self.script = script
        self.flags = flags
        self.filename = filename

    def asdict(self) -> '_ScriptData':
        return dict(name=self.name, script=self.script, filename=self.filename)

    @classmethod
    def fromdict(cls, state: '_ScriptData') -> 'Script':
        return Script(state["name"], state["script"], filename=state["filename"])


class ScriptItemDelegate(QStyledItemDelegate):
    # pylint: disable=no-self-use
    def displayText(self, script, _locale):
        if script.flags & Script.Modified:
            return "*" + script.name
        else:
            return script.name

    def paint(self, painter, option, index):
        script = index.data(Qt.DisplayRole)

        if script.flags & Script.Modified:
            option = QStyleOptionViewItem(option)
            option.palette.setColor(QPalette.Text, QColor(Qt.red))
            option.palette.setColor(QPalette.Highlight, QColor(Qt.darkRed))
        super().paint(painter, option, index)

    def createEditor(self, parent, _option, _index):
        return QLineEdit(parent)

    def setEditorData(self, editor, index):
        script = index.data(Qt.DisplayRole)
        editor.setText(script.name)

    def setModelData(self, editor, model, index):
        model[index.row()].name = str(editor.text())


def select_row(view, row):
    """
    Select a `row` in an item view
    """
    selmodel = view.selectionModel()
    selmodel.select(view.model().index(row, 0),
                    QItemSelectionModel.ClearAndSelect)


if TYPE_CHECKING:
    # pylint: disable=used-before-assignment
    _ScriptData = TypedDict("_ScriptData", {
        "name": str, "script": str, "filename": Optional[str]
    })


class OWPythonScript(OWWidget):
    name = "Python Script"
    description = "Write a Python script and run it on input data or models."
    icon = "icons/PythonScript.svg"
    priority = 3150
    keywords = ["file", "program"]

    class Inputs:
        data = Input("Data", Table, replaces=["in_data"],
                     default=True, multiple=True)
        learner = Input("Learner", Learner, replaces=["in_learner"],
                        default=True, multiple=True)
        classifier = Input("Classifier", Model, replaces=["in_classifier"],
                           default=True, multiple=True)
        object = Input("Object", object, replaces=["in_object"],
                       default=False, multiple=True)

    class Outputs:
        data = Output("Data", Table, replaces=["out_data"])
        learner = Output("Learner", Learner, replaces=["out_learner"])
        classifier = Output("Classifier", Model, replaces=["out_classifier"])
        object = Output("Object", object, replaces=["out_object"])

    signal_names = ("data", "learner", "classifier", "object")

    settings_version = 2
    scriptLibrary: 'List[_ScriptData]' = Setting([{
        "name": "Hello world",
        "script": "print('Hello world')\n",
        "filename": None
    }])
    currentScriptIndex = Setting(0)
    scriptText: Optional[str] = Setting(None, schema_only=True)
    splitterState: Optional[bytes] = Setting(None)

    # Widgets in the same schema share namespace through a dictionary whose
    # key is self.signalManager. ales-erjavec expressed concern (and I fully
    # agree!) about widget being aware of the outside world. I am leaving this
    # anyway. If this causes any problems in the future, replace this with
    # shared_namespaces = {} and thus use a common namespace for all instances
    # of # PythonScript even if they are in different schemata.
    shared_namespaces = weakref.WeakKeyDictionary()

    class Error(OWWidget.Error):
        pass

    def __init__(self):
        super().__init__()
        self.libraryListSource = []

        for name in self.signal_names:
            setattr(self, name, {})

        self._cachedDocuments = {}

        self.infoBox = gui.vBox(self.controlArea, 'Info')
        gui.label(
            self.infoBox, self,
            "<p>Execute python script.</p><p>Input variables:<ul><li> " +
            "<li>".join(map("in_{0}, in_{0}s".format, self.signal_names)) +
            "</ul></p><p>Output variables:<ul><li>" +
            "<li>".join(map("out_{0}".format, self.signal_names)) +
            "</ul></p>"
        )

        self.libraryList = itemmodels.PyListModel(
            [], self,
            flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)

        self.libraryList.wrap(self.libraryListSource)

        self.controlBox = gui.vBox(self.controlArea, 'Library')
        self.controlBox.layout().setSpacing(1)

        self.libraryView = QListView(
            editTriggers=QListView.DoubleClicked |
            QListView.EditKeyPressed,
            sizePolicy=QSizePolicy(QSizePolicy.Ignored,
                                   QSizePolicy.Preferred)
        )
        self.libraryView.setItemDelegate(ScriptItemDelegate(self))
        self.libraryView.setModel(self.libraryList)

        self.libraryView.selectionModel().selectionChanged.connect(
            self.onSelectedScriptChanged
        )
        self.controlBox.layout().addWidget(self.libraryView)

        w = itemmodels.ModelActionsWidget()

        self.addNewScriptAction = action = QAction("+", self)
        action.setToolTip("Add a new script to the library")
        action.triggered.connect(self.onAddScript)
        w.addAction(action)

        action = QAction(unicodedata.lookup("MINUS SIGN"), self)
        action.setToolTip("Remove script from library")
        action.triggered.connect(self.onRemoveScript)
        w.addAction(action)

        action = QAction("Update", self)
        action.setToolTip("Save changes in the editor to library")
        action.setShortcut(QKeySequence(QKeySequence.Save))
        action.triggered.connect(self.commitChangesToLibrary)
        w.addAction(action)

        action = QAction("More", self, toolTip="More actions")

        new_from_file = QAction("Import Script from File", self)
        save_to_file = QAction("Save Selected Script to File", self)
        restore_saved = QAction("Undo Changes to Selected Script", self)
        save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))

        new_from_file.triggered.connect(self.onAddScriptFromFile)
        save_to_file.triggered.connect(self.saveScript)
        restore_saved.triggered.connect(self.restoreSaved)

        menu = QMenu(w)
        menu.addAction(new_from_file)
        menu.addAction(save_to_file)
        menu.addAction(restore_saved)
        action.setMenu(menu)
        button = w.addAction(action)
        button.setPopupMode(QToolButton.InstantPopup)

        w.layout().setSpacing(1)

        self.controlBox.layout().addWidget(w)

        self.execute_button = gui.button(self.controlArea, self, 'Run', callback=self.commit)

        run = QAction("Run script", self, triggered=self.commit,
                      shortcut=QKeySequence(Qt.ControlModifier | Qt.Key_R))
        self.addAction(run)

        self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)
        self.mainArea.layout().addWidget(self.splitCanvas)

        self.defaultFont = defaultFont = \
            "Monaco" if sys.platform == "darwin" else "Courier"

        self.textBox = gui.vBox(self, 'Python Script')
        self.splitCanvas.addWidget(self.textBox)
        self.text = PythonScriptEditor(self)
        self.textBox.layout().addWidget(self.text)

        self.textBox.setAlignment(Qt.AlignVCenter)
        self.text.setTabStopWidth(4)

        self.text.modificationChanged[bool].connect(self.onModificationChanged)

        self.saveAction = action = QAction("&Save", self.text)
        action.setToolTip("Save script to file")
        action.setShortcut(QKeySequence(QKeySequence.Save))
        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        action.triggered.connect(self.saveScript)

        self.consoleBox = gui.vBox(self, 'Console')
        self.splitCanvas.addWidget(self.consoleBox)
        self.console = PythonConsole({}, self)
        self.consoleBox.layout().addWidget(self.console)
        self.console.document().setDefaultFont(QFont(defaultFont))
        self.consoleBox.setAlignment(Qt.AlignBottom)
        self.console.setTabStopWidth(4)
        self.splitCanvas.setSizes([2, 1])
        self.setAcceptDrops(True)
        self.controlArea.layout().addStretch(10)

        self._restoreState()
        self.settingsAboutToBePacked.connect(self._saveState)

    def sizeHint(self) -> QSize:
        return super().sizeHint().expandedTo(QSize(800, 600))

    def _restoreState(self):
        self.libraryListSource = [Script.fromdict(s) for s in self.scriptLibrary]
        self.libraryList.wrap(self.libraryListSource)
        select_row(self.libraryView, self.currentScriptIndex)

        if self.scriptText is not None:
            current = self.text.toPlainText()
            # do not mark scripts as modified
            if self.scriptText != current:
                self.text.document().setPlainText(self.scriptText)

        if self.splitterState is not None:
            self.splitCanvas.restoreState(QByteArray(self.splitterState))

    def _saveState(self):
        self.scriptLibrary = [s.asdict() for s in self.libraryListSource]
        self.scriptText = self.text.toPlainText()
        self.splitterState = bytes(self.splitCanvas.saveState())

    def handle_input(self, obj, sig_id, signal):
        sig_id = sig_id[0]
        dic = getattr(self, signal)
        if obj is None:
            if sig_id in dic.keys():
                del dic[sig_id]
        else:
            dic[sig_id] = obj

    @Inputs.data
    def set_data(self, data, sig_id):
        self.handle_input(data, sig_id, "data")

    @Inputs.learner
    def set_learner(self, data, sig_id):
        self.handle_input(data, sig_id, "learner")

    @Inputs.classifier
    def set_classifier(self, data, sig_id):
        self.handle_input(data, sig_id, "classifier")

    @Inputs.object
    def set_object(self, data, sig_id):
        self.handle_input(data, sig_id, "object")

    def handleNewSignals(self):
        self.commit()

    def selectedScriptIndex(self):
        rows = self.libraryView.selectionModel().selectedRows()
        if rows:
            return [i.row() for i in rows][0]
        else:
            return None

    def setSelectedScript(self, index):
        select_row(self.libraryView, index)

    def onAddScript(self, *_):
        self.libraryList.append(Script("New script", self.text.toPlainText(), 0))
        self.setSelectedScript(len(self.libraryList) - 1)

    def onAddScriptFromFile(self, *_):
        filename, _ = QFileDialog.getOpenFileName(
            self, 'Open Python Script',
            os.path.expanduser("~/"),
            'Python files (*.py)\nAll files(*.*)'
        )
        if filename:
            name = os.path.basename(filename)
            # TODO: use `tokenize.detect_encoding`
            with open(filename, encoding="utf-8") as f:
                contents = f.read()
            self.libraryList.append(Script(name, contents, 0, filename))
            self.setSelectedScript(len(self.libraryList) - 1)

    def onRemoveScript(self, *_):
        index = self.selectedScriptIndex()
        if index is not None:
            del self.libraryList[index]
            select_row(self.libraryView, max(index - 1, 0))

    def onSaveScriptToFile(self, *_):
        index = self.selectedScriptIndex()
        if index is not None:
            self.saveScript()

    def onSelectedScriptChanged(self, selected, _deselected):
        index = [i.row() for i in selected.indexes()]
        if index:
            current = index[0]
            if current >= len(self.libraryList):
                self.addNewScriptAction.trigger()
                return

            self.text.setDocument(self.documentForScript(current))
            self.currentScriptIndex = current

    def documentForScript(self, script=0):
        if not isinstance(script, Script):
            script = self.libraryList[script]
        if script not in self._cachedDocuments:
            doc = QTextDocument(self)
            doc.setDocumentLayout(QPlainTextDocumentLayout(doc))
            doc.setPlainText(script.script)
            doc.setDefaultFont(QFont(self.defaultFont))
            doc.highlighter = PythonSyntaxHighlighter(doc)
            doc.modificationChanged[bool].connect(self.onModificationChanged)
            doc.setModified(False)
            self._cachedDocuments[script] = doc
        return self._cachedDocuments[script]

    def commitChangesToLibrary(self, *_):
        index = self.selectedScriptIndex()
        if index is not None:
            self.libraryList[index].script = self.text.toPlainText()
            self.text.document().setModified(False)
            self.libraryList.emitDataChanged(index)

    def onModificationChanged(self, modified):
        index = self.selectedScriptIndex()
        if index is not None:
            self.libraryList[index].flags = Script.Modified if modified else 0
            self.libraryList.emitDataChanged(index)

    def restoreSaved(self):
        index = self.selectedScriptIndex()
        if index is not None:
            self.text.document().setPlainText(self.libraryList[index].script)
            self.text.document().setModified(False)

    def saveScript(self):
        index = self.selectedScriptIndex()
        if index is not None:
            script = self.libraryList[index]
            filename = script.filename
        else:
            filename = os.path.expanduser("~/")

        filename, _ = QFileDialog.getSaveFileName(
            self, 'Save Python Script',
            filename,
            'Python files (*.py)\nAll files(*.*)'
        )

        if filename:
            fn = ""
            head, tail = os.path.splitext(filename)
            if not tail:
                fn = head + ".py"
            else:
                fn = filename

            f = open(fn, 'w')
            f.write(self.text.toPlainText())
            f.close()

    def initial_locals_state(self):
        d = self.shared_namespaces.setdefault(self.signalManager, {}).copy()
        for name in self.signal_names:
            value = getattr(self, name)
            all_values = list(value.values())
            one_value = all_values[0] if len(all_values) == 1 else None
            d["in_" + name + "s"] = all_values
            d["in_" + name] = one_value
        return d

    def update_namespace(self, namespace):
        not_saved = reduce(set.union,
                           ({f"in_{name}s", f"in_{name}", f"out_{name}"}
                            for name in self.signal_names))
        self.shared_namespaces.setdefault(self.signalManager, {}).update(
            {name: value for name, value in namespace.items()
             if name not in not_saved})

    def commit(self):
        self.Error.clear()
        lcls = self.initial_locals_state()
        lcls["_script"] = str(self.text.toPlainText())
        self.console.updateLocals(lcls)
        self.console.write("\nRunning script:\n")
        self.console.push("exec(_script)")
        self.console.new_prompt(sys.ps1)
        self.update_namespace(self.console.locals)
        for signal in self.signal_names:
            out_var = self.console.locals.get("out_" + signal)
            signal_type = getattr(self.Outputs, signal).type
            if not isinstance(out_var, signal_type) and out_var is not None:
                self.Error.add_message(signal,
                                       "'{}' has to be an instance of '{}'.".
                                       format(signal, signal_type.__name__))
                getattr(self.Error, signal)()
                out_var = None
            getattr(self.Outputs, signal).send(out_var)

    def dragEnterEvent(self, event):  # pylint: disable=no-self-use
        urls = event.mimeData().urls()
        if urls:
            # try reading the file as text
            c = read_file_content(urls[0].toLocalFile(), limit=1000)
            if c is not None:
                event.acceptProposedAction()

    def dropEvent(self, event):
        """Handle file drops"""
        urls = event.mimeData().urls()
        if urls:
            self.text.pasteFile(urls[0])

    @classmethod
    def migrate_settings(cls, settings, version):
        if version is not None and version < 2:
            scripts = settings.pop("libraryListSource")  # type: List[Script]
            library = [dict(name=s.name, script=s.script, filename=s.filename)
                       for s in scripts]  # type: List[_ScriptData]
            settings["scriptLibrary"] = library


if __name__ == "__main__":  # pragma: no cover
    WidgetPreview(OWPythonScript).run()

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
user