Repository: spyder-ide/spyder

Issue:
Ctrl+V causes a crash
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

Not sure why, but pasting a simple string like

> import analyseData as ad

causes an error popup. This happens on both my work PC and home PC.

### Traceback
```python-traceback
Traceback (most recent call last):
  File "C:\Program Files\Spyder\pkgs\spyder\plugins\editor\widgets\codeeditor.py", line 2813, in paste
    for line in remaining_lines]
  File "C:\Program Files\Spyder\pkgs\spyder\plugins\editor\widgets\codeeditor.py", line 2813, in <listcomp>
    for line in remaining_lines]
  File "C:\Program Files\Spyder\pkgs\spyder\plugins\editor\widgets\codeeditor.py", line 2732, in adjust_indentation
    * indent_adjustment // self.tab_stop_width_spaces
TypeError: unsupported operand type(s) for //: 'str' and 'int'
```

## Versions

* Spyder version: 5.1.0 
* Python version: 3.7.9
* Qt version: 5.12.10
* PyQt5 version: 5.12.3
* Operating System: Windows 10

### Dependencies

```

# Mandatory:
atomicwrites >=1.2.0                         :  1.4.0 (OK)
chardet >=2.0.0                              :  4.0.0 (OK)
cloudpickle >=0.5.0                          :  1.6.0 (OK)
cookiecutter >=1.6.0                         :  1.7.3 (OK)
diff_match_patch >=20181111                  :  20200713 (OK)
intervaltree                                 :  None (OK)
IPython >=7.6.0                              :  7.26.0 (OK)
jedi >=0.17.2;<0.19.0                        :  0.18.0 (OK)
jsonschema >=3.2.0                           :  3.2.0 (OK)
keyring >=17.0.0                             :  23.0.1 (OK)
nbconvert >=4.0                              :  6.1.0 (OK)
numpydoc >=0.6.0                             :  1.1.0 (OK)
paramiko >=2.4.0                             :  2.7.2 (OK)
parso >=0.7.0;<0.9.0                         :  0.8.2 (OK)
pexpect >=4.4.0                              :  4.8.0 (OK)
pickleshare >=0.4                            :  0.7.5 (OK)
psutil >=5.3                                 :  5.8.0 (OK)
pygments >=2.0                               :  2.9.0 (OK)
pylint >=2.5.0                               :  2.9.6 (OK)
pyls_spyder >=0.4.0                          :  0.4.0 (OK)
pylsp >=1.2.0;<1.3.0                         :  1.2.0 (OK)
pylsp_black >=1.0.0                          :  None (OK)
qdarkstyle =3.0.2                            :  3.0.2 (OK)
qstylizer >=0.1.10                           :  0.2.1 (OK)
qtawesome >=1.0.2                            :  1.0.3 (OK)
qtconsole >=5.1.0                            :  5.1.1 (OK)
qtpy >=1.5.0                                 :  1.9.0 (OK)
rtree >=0.9.7                                :  0.9.7 (OK)
setuptools >=49.6.0                          :  57.4.0 (OK)
sphinx >=0.6.6                               :  4.1.2 (OK)
spyder_kernels >=2.1.0;<2.2.0                :  2.1.0 (OK)
textdistance >=4.2.0                         :  4.2.1 (OK)
three_merge >=0.1.1                          :  0.1.1 (OK)
watchdog                                     :  2.1.3 (OK)
zmq >=17                                     :  22.1.0 (OK)

# Optional:
cython >=0.21                                :  0.29.24 (OK)
matplotlib >=2.0.0                           :  3.4.2 (OK)
numpy >=1.7                                  :  1.19.3 (OK)
pandas >=1.1.1                               :  1.3.1 (OK)
scipy >=0.17.0                               :  1.7.1 (OK)
sympy >=0.7.3                                :  1.8 (OK)

# Spyder plugins:
spyder.plugins.completion.plugin 5.1.0       :  5.1.0 (OK)
spyder.plugins.outlineexplorer.plugin 5.1.0  :  5.1.0 (OK)
spyder.plugins.projects.plugin 5.1.0         :  5.1.0 (OK)
spyder.plugins.variableexplorer.plugin 5.1.0 :  5.1.0 (OK)
```



Discussion:
Hey @marco-sky, thanks for reporting. I'll try to fix this problem in our next release.

Resolving patch:
diff --git a/spyder/plugins/editor/widgets/codeeditor.py b/spyder/plugins/editor/widgets/codeeditor.py
--- a/spyder/plugins/editor/widgets/codeeditor.py
+++ b/spyder/plugins/editor/widgets/codeeditor.py
@@ -889,7 +889,7 @@ def setup_editor(self,
         self.toggle_identation_guides(indent_guides)
         if self.indent_chars == '\t':
             self.indent_guides.set_indentation_width(
-                self.tab_stop_width_spaces)
+                tab_stop_width_spaces)
         else:
             self.indent_guides.set_indentation_width(len(self.indent_chars))
 
@@ -2740,6 +2740,12 @@ def adjust_indentation(self, line, indent_adjustment):
             if using_spaces:
                 return ' ' * indent_adjustment + line
             else:
+                # Make sure tab_stop_width_spaces is an int at this point.
+                # Fixes spyder-ide/spyder#16137
+                if not isinstance(self.tab_stop_width_spaces, int):
+                    # Set default value
+                    self.tab_stop_width_spaces = 4
+
                 return (
                     self.indent_chars
                     * indent_adjustment // self.tab_stop_width_spaces


Test patch: