# Buggy code
def run_script(
    self,
    filename,
    wdir,
    args,
    debug,
    post_mortem,
    current_client,
    clear_variables,
    console_namespace,
):
    """Run script in current or dedicated client"""
    norm = lambda text: remove_backslashes(to_text_string(text))

    # Run Cython files in a dedicated console
    is_cython = osp.splitext(filename)[1] == ".pyx"
    if is_cython:
        current_client = False

    # Select client to execute code on it
    is_new_client = False
    if current_client:
        client = self.get_current_client()
    else:
        client = self.get_client_for_file(filename)
        if client is None:
            self.create_client_for_file(filename, is_cython=is_cython)
            client = self.get_current_client()
            is_new_client = True

    if client is not None:
        # Internal kernels, use runfile
        if client.get_kernel() is not None:
            line = "%s('%s'" % ("debugfile" if debug else "runfile", norm(filename))
            if args:
                line += ", args='%s'" % norm(args)
            if wdir:
                line += ", wdir='%s'" % norm(wdir)
            if post_mortem:
                line += ", post_mortem=True"
            if console_namespace:
                line += ", current_namespace=True"
            line += ")"
        else:  # External kernels, use %run
            line = "%run "
            if debug:
                line += "-d "
            line += '"%s"' % to_text_string(filename)
            if args:
                line += " %s" % norm(args)

        try:
            if client.shellwidget._executing:
                # Don't allow multiple executions when there's
                # still an execution taking place
                # Fixes spyder-ide/spyder#7293.
                pass
            elif client.shellwidget._reading:
                client.shellwidget._append_html(
                    _(
                        "<br><b>Please exit from debugging before trying to "
                        "run a file in this console.</b>\n<hr><br>"
                    ),
                    before_prompt=True,
                )
                return
            elif current_client:
                self.execute_code(line, current_client, clear_variables)
            else:
                if is_new_client:
                    client.shellwidget.silent_execute("%clear")
                else:
                    client.shellwidget.execute("%clear")
                client.shellwidget.sig_prompt_ready.connect(
                    lambda: self.execute_code(line, current_client, clear_variables)
                )
        except AttributeError:
            pass
        self.switch_to_plugin()
    else:
        # XXX: not sure it can really happen
        QMessageBox.warning(
            self,
            _("Warning"),
            _(
                "No IPython console is currently available to run <b>%s</b>."
                "<br><br>Please open a new one and try again."
            )
            % osp.basename(filename),
            QMessageBox.Ok,
        )


# Traceback (RuntimeError)
File "C:\Users\Chan Chak Tong\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\editor.py", line 2551, in run_cell
self._run_cell_text(text, block)
File "C:\Users\Chan Chak Tong\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\editor.py", line 2614, in _run_cell_text
cell_name = self._get_cell_name(block)
File "C:\Users\Chan Chak Tong\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\editor.py", line 2595, in _get_cell_name
raise RuntimeError('Not a cell?')
RuntimeError: Not a cell?
WARNING:spyder.widgets.github.backend:Failed to send bug report on Github. response={'code': 401, 'json': {'message': 'Bad credentials', 'documentation_url': 'https://developer.github.com/v3'}}

# Fixed code
def run_script(
    self,
    filename,
    wdir,
    args,
    debug,
    post_mortem,
    current_client,
    clear_variables,
    console_namespace,
):
    """Run script in current or dedicated client"""
    norm = lambda text: remove_backslashes(to_text_string(text))

    # Run Cython files in a dedicated console
    is_cython = osp.splitext(filename)[1] == ".pyx"
    if is_cython:
        current_client = False

    # Select client to execute code on it
    is_new_client = False
    if current_client:
        client = self.get_current_client()
    else:
        client = self.get_client_for_file(filename)
        if client is None:
            self.create_client_for_file(filename, is_cython=is_cython)
            client = self.get_current_client()
            is_new_client = True

    if client is not None:
        # Internal kernels, use runfile
        if client.get_kernel() is not None:
            line = "%s('%s'" % ("debugfile" if debug else "runfile", norm(filename))
            if args:
                line += ", args='%s'" % norm(args)
            if wdir:
                line += ", wdir='%s'" % norm(wdir)
            if post_mortem:
                line += ", post_mortem=True"
            if console_namespace:
                line += ", current_namespace=True"
            line += ")"
        else:  # External kernels, use %run
            line = "%run "
            if debug:
                line += "-d "
            line += '"%s"' % to_text_string(filename)
            if args:
                line += " %s" % norm(args)

        try:
            if client.shellwidget._executing:
                # Don't allow multiple executions when there's
                # still an execution taking place
                # Fixes spyder-ide/spyder#7293.
                pass
            elif client.shellwidget._reading and client.shellwidget.is_debugging():
                client.shellwidget.write_to_stdin("!" + line)
            elif current_client:
                self.execute_code(line, current_client, clear_variables)
            else:
                if is_new_client:
                    client.shellwidget.silent_execute("%clear")
                else:
                    client.shellwidget.execute("%clear")
                client.shellwidget.sig_prompt_ready.connect(
                    lambda: self.execute_code(line, current_client, clear_variables)
                )
        except AttributeError:
            pass
        self.switch_to_plugin()
    else:
        # XXX: not sure it can really happen
        QMessageBox.warning(
            self,
            _("Warning"),
            _(
                "No IPython console is currently available to run <b>%s</b>."
                "<br><br>Please open a new one and try again."
            )
            % osp.basename(filename),
            QMessageBox.Ok,
        )