[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1009659: bullseye-pu: package spyder/4.2.1+dfsg1-3



Package: release.debian.org
Severity: normal
Tags: bullseye
User: release.debian.org@packages.debian.org
Usertags: pu

(Please provide enough information to help the release team
to judge the request efficiently. E.g. by filling in the
sections below.)

[ Reason ]
(Explain what the reason for the (old-)stable update is. I.e.
what is the bug, when was it introduced, is this a regression
with respect to the previous (old-)stable.)

The bug is reported in https://bugs.debian.org/989660
I didn't spot it at the time because I'm only an uploader, not the
named maintainer, and had forgotten to check the BTS.  Sorry about
that.  The bug was present in version 4.2.1 of Spyder, but was fixed
by upstream in version 4.2.2.

The bug means that in some cases when the black code formatter is
used, the code is modified before being saved (rather than just being
reformatted).  This is likely to cause bugs in the user's code.

[ Impact ]
(What is the impact for the user if the update isn't approved?)

As noted above, this might silently corrupt code that the user is
editing.

[ Tests ]
(What automated or manual tests cover the affected code?)

Unfortunately there are no tests in the stable version of this
package.  (This has been rectified in unstable.)

[ Risks ]
(Discussion of the risks involved. E.g. code is trivial or
complex, alternatives available.)

This patch is moderately complex; it appears to fix the issue and it
was approved by the core Spyder maintainer, who is very sharp-eyed.
It is also present in the current version of Spyder (uploaded to
unstable within the last few days).  There are no alternatives I am
aware of.

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in (old)stable
  [x] the issue is verified as fixed in unstable

[ Changes ]
(Explain *all* the changes)

Applying the upstream patch is the only change made.

[ Other info ]
(Anything else the release team should know.)

I have not yet uploaded it to bullseye; I await your instructions.

Best wishes,

   Julian
diff -Nru spyder-4.2.1+dfsg1/debian/changelog spyder-4.2.1+dfsg1/debian/changelog
--- spyder-4.2.1+dfsg1/debian/changelog	2021-02-21 09:28:17.000000000 +0000
+++ spyder-4.2.1+dfsg1/debian/changelog	2022-04-13 19:05:26.000000000 +0100
@@ -1,3 +1,9 @@
+spyder (4.2.1+dfsg1-3+deb11u1) bullseye; urgency=medium
+
+  * Fix duplicate-code-on-save bug (closes: #989660)
+
+ -- Julian Gilbey <jdg@debian.org>  Wed, 13 Apr 2022 19:05:26 +0100
+
 spyder (4.2.1+dfsg1-3) unstable; urgency=medium
 
   * Missed one dependency (python3-setuptools) in the last upload, and
diff -Nru spyder-4.2.1+dfsg1/debian/patches/Prevent-double-saving-when-running-a-file.patch spyder-4.2.1+dfsg1/debian/patches/Prevent-double-saving-when-running-a-file.patch
--- spyder-4.2.1+dfsg1/debian/patches/Prevent-double-saving-when-running-a-file.patch	1970-01-01 01:00:00.000000000 +0100
+++ spyder-4.2.1+dfsg1/debian/patches/Prevent-double-saving-when-running-a-file.patch	2022-04-13 19:05:26.000000000 +0100
@@ -0,0 +1,183 @@
+From: Edgar Andrés Margffoy Tuay <andfoy@gmail.com>
+Subject: Prevent double saving when running a file
+  This patch has had the line-endings converted to make it compatible
+Origin: upstream, https://github.com/spyder-ide/spyder/pull/14759
+Applied-Upstream: https://github.com/spyder-ide/spyder/commit/9325d0d7be1a88602b8092d35be309edc876aa38
+Bug: https://github.com/spyder-ide/spyder/issues/14653
+Bug-Debian: http://bugs.debian.org/989660
+Last-Update: 2022-04-13
+
+---
+ spyder/plugins/editor/plugin.py         | 130 ++++++++++++------------
+ spyder/plugins/editor/widgets/editor.py |   4 +-
+ 2 files changed, 69 insertions(+), 65 deletions(-)
+
+diff --git a/spyder/plugins/editor/plugin.py b/spyder/plugins/editor/plugin.py
+index 1faec3c82..8034714a0 100644
+--- a/spyder/plugins/editor/plugin.py
++++ b/spyder/plugins/editor/plugin.py
+@@ -2567,72 +2567,72 @@ def edit_run_configurations(self):
+     def run_file(self, debug=False):
+         """Run script inside current interpreter or in a new one"""
+         editorstack = self.get_current_editorstack()
+-        if editorstack.save(save_new_files=False):
+-            editor = self.get_current_editor()
+-            fname = osp.abspath(self.get_current_filename())
+-
+-            # Get fname's dirname before we escape the single and double
+-            # quotes. Fixes spyder-ide/spyder#6771.
+-            dirname = osp.dirname(fname)
+ 
+-            # Escape single and double quotes in fname and dirname.
+-            # Fixes spyder-ide/spyder#2158.
+-            fname = fname.replace("'", r"\'").replace('"', r'\"')
+-            dirname = dirname.replace("'", r"\'").replace('"', r'\"')
++        editor = self.get_current_editor()
++        fname = osp.abspath(self.get_current_filename())
+ 
+-            runconf = get_run_configuration(fname)
+-            if runconf is None:
+-                dialog = RunConfigOneDialog(self)
+-                dialog.size_change.connect(lambda s: self.set_dialog_size(s))
+-                if self.dialog_size is not None:
+-                    dialog.resize(self.dialog_size)
+-                dialog.setup(fname)
+-                if CONF.get('run', 'open_at_least_once',
+-                            not running_under_pytest()):
+-                    # Open Run Config dialog at least once: the first time
+-                    # a script is ever run in Spyder, so that the user may
+-                    # see it at least once and be conscious that it exists
+-                    show_dlg = True
+-                    CONF.set('run', 'open_at_least_once', False)
+-                else:
+-                    # Open Run Config dialog only
+-                    # if ALWAYS_OPEN_FIRST_RUN_OPTION option is enabled
+-                    show_dlg = CONF.get('run', ALWAYS_OPEN_FIRST_RUN_OPTION)
+-                if show_dlg and not dialog.exec_():
+-                    return
+-                runconf = dialog.get_configuration()
+-
+-            args = runconf.get_arguments()
+-            python_args = runconf.get_python_arguments()
+-            interact = runconf.interact
+-            post_mortem = runconf.post_mortem
+-            current = runconf.current
+-            systerm = runconf.systerm
+-            clear_namespace = runconf.clear_namespace
+-            console_namespace = runconf.console_namespace
+-
+-            if runconf.file_dir:
+-                wdir = dirname
+-            elif runconf.cw_dir:
+-                wdir = ''
+-            elif osp.isdir(runconf.dir):
+-                wdir = runconf.dir
++        # Get fname's dirname before we escape the single and double
++        # quotes. Fixes spyder-ide/spyder#6771.
++        dirname = osp.dirname(fname)
++
++        # Escape single and double quotes in fname and dirname.
++        # Fixes spyder-ide/spyder#2158.
++        fname = fname.replace("'", r"\'").replace('"', r'\"')
++        dirname = dirname.replace("'", r"\'").replace('"', r'\"')
++
++        runconf = get_run_configuration(fname)
++        if runconf is None:
++            dialog = RunConfigOneDialog(self)
++            dialog.size_change.connect(lambda s: self.set_dialog_size(s))
++            if self.dialog_size is not None:
++                dialog.resize(self.dialog_size)
++            dialog.setup(fname)
++            if CONF.get('run', 'open_at_least_once',
++                        not running_under_pytest()):
++                # Open Run Config dialog at least once: the first time
++                # a script is ever run in Spyder, so that the user may
++                # see it at least once and be conscious that it exists
++                show_dlg = True
++                CONF.set('run', 'open_at_least_once', False)
+             else:
+-                wdir = ''
+-
+-            python = True # Note: in the future, it may be useful to run
+-            # something in a terminal instead of a Python interp.
+-            self.__last_ec_exec = (fname, wdir, args, interact, debug,
+-                                   python, python_args, current, systerm,
+-                                   post_mortem, clear_namespace,
+-                                   console_namespace)
+-            self.re_run_file(save_new_files=False)
+-            if not interact and not debug:
+-                # If external console dockwidget is hidden, it will be
+-                # raised in top-level and so focus will be given to the
+-                # current external shell automatically
+-                # (see SpyderPluginWidget.visibility_changed method)
+-                editor.setFocus()
++                # Open Run Config dialog only
++                # if ALWAYS_OPEN_FIRST_RUN_OPTION option is enabled
++                show_dlg = CONF.get('run', ALWAYS_OPEN_FIRST_RUN_OPTION)
++            if show_dlg and not dialog.exec_():
++                return
++            runconf = dialog.get_configuration()
++
++        args = runconf.get_arguments()
++        python_args = runconf.get_python_arguments()
++        interact = runconf.interact
++        post_mortem = runconf.post_mortem
++        current = runconf.current
++        systerm = runconf.systerm
++        clear_namespace = runconf.clear_namespace
++        console_namespace = runconf.console_namespace
++
++        if runconf.file_dir:
++            wdir = dirname
++        elif runconf.cw_dir:
++            wdir = ''
++        elif osp.isdir(runconf.dir):
++            wdir = runconf.dir
++        else:
++            wdir = ''
++
++        python = True # Note: in the future, it may be useful to run
++        # something in a terminal instead of a Python interp.
++        self.__last_ec_exec = (fname, wdir, args, interact, debug,
++                                python, python_args, current, systerm,
++                                post_mortem, clear_namespace,
++                                console_namespace)
++        self.re_run_file(save_new_files=False)
++        if not interact and not debug:
++            # If external console dockwidget is hidden, it will be
++            # raised in top-level and so focus will be given to the
++            # current external shell automatically
++            # (see SpyderPluginWidget.visibility_changed method)
++            editor.setFocus()
+ 
+     def set_dialog_size(self, size):
+         self.dialog_size = size
+@@ -2650,7 +2650,9 @@ def debug_file(self):
+     def re_run_file(self, save_new_files=True):
+         """Re-run last script"""
+         if self.get_option('save_all_before_run'):
+-            self.save_all(save_new_files=save_new_files)
++            all_saved = self.save_all(save_new_files=save_new_files)
++            if not all_saved:
++                return
+         if self.__last_ec_exec is None:
+             return
+         (fname, wdir, args, interact, debug,
+diff --git a/spyder/plugins/editor/widgets/editor.py b/spyder/plugins/editor/widgets/editor.py
+index cfcbca478..3c5d61e75 100644
+--- a/spyder/plugins/editor/widgets/editor.py
++++ b/spyder/plugins/editor/widgets/editor.py
+@@ -2265,9 +2265,11 @@ def save_all(self, save_new_files=True):
+ 
+         Iterate through self.data and call save() on any modified files.
+         """
++        all_saved = True
+         for index in range(self.get_stack_count()):
+             if self.data[index].editor.document().isModified():
+-                self.save(index, save_new_files=save_new_files)
++                all_saved &= self.save(index, save_new_files=save_new_files)
++        return all_saved
+ 
+     #------ Update UI
+     def start_stop_analysis_timer(self):
+
diff -Nru spyder-4.2.1+dfsg1/debian/patches/series spyder-4.2.1+dfsg1/debian/patches/series
--- spyder-4.2.1+dfsg1/debian/patches/series	2021-02-21 09:28:17.000000000 +0000
+++ spyder-4.2.1+dfsg1/debian/patches/series	2022-04-13 19:05:26.000000000 +0100
@@ -4,3 +4,4 @@
 0004-Removed-pylint-dependency.patch
 0005-fix-implicit-int-conversion.patch
 0006-quieten-dependency-warning
+Prevent-double-saving-when-running-a-file.patch

Reply to: