Repository: spyder-ide/spyder

Issue:
Triple quotes in a code cell breaks runcell
## Problem Description

If a triple quotes is present in the code of the cell, running the cell returns an error instead of running as expected.

### What steps reproduce the problem?

1. Create a new file with the following content in the Editor :
```python
# %%
"""
test
"""
# %%
```
2. Run the cell (Ctrl + Enter or Shift + Enter).

### Paste Traceback/Error Below (if applicable)
<!--- Copy from error dialog or View > Panes > Internal Console --->

```python-traceback
runcell('','C:/Users/User/OneDrive/Research/PostDoc - MDDELCC/Analyses Baro/untitled0.py')
  File "<ipython-input-11-7f05e5d89a67>", line 7
    \"\"\"
          ^
SyntaxError: unexpected character after line continuation character
```

## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version: Spyder 4.0.0.dev0 https://github.com/spyder-ide/spyder/commit/ac3b24db9ee01ba12ff1044435d3abdea659878d
* Python version: Python 3.6.6 64-bit
* Qt version: Qt 5.9.4
* PyQt version: PyQt5 5.9.2
* Operating System name/version: Windows 10 

### Dependencies
<!--- Please go to the menu entry Help > Dependencies,
press the Copy to clipboard button and paste below --->

```
pygments >=2.0    :  2.2.0 (OK)
sphinx >=0.6.6    :  1.8.1 (OK)
pyls >=0.19.0     :  0.19.0 (OK)
nbconvert >=4.0   :  5.3.1 (OK)
pandas >=0.13.1   :  0.23.4 (OK)
numpy >=1.7       :  1.15.2 (OK)
sympy >=0.7.3     :  None (NOK)
cython >=0.21     :  None (NOK)
qtconsole >=4.2.0 :  4.5.0.dev0 (OK)
IPython >=4.0     :  7.0.1 (OK)
matplotlib >=2.0.0:  None (NOK)
pylint >=0.25     :  2.1.1 (OK)
```



Discussion:
Wow the raw string didn't do me any favors with the triple quote escaping.

I think instead of a raw string I might just replace all the `\` with `\\` before I escape the triple quotes. I think this should work. Any corner cases or better solution here I'm not thinking of?


Resolving patch:
diff --git a/spyder/plugins/ipythonconsole/plugin.py b/spyder/plugins/ipythonconsole/plugin.py
--- a/spyder/plugins/ipythonconsole/plugin.py
+++ b/spyder/plugins/ipythonconsole/plugin.py
@@ -936,8 +936,9 @@ def norm(text):
                     if is_internal_kernel:
                         client.shellwidget.silent_execute(
                             to_text_string('get_ipython().cell_code = '
-                                           'r"""{}"""')
+                                           '"""{}"""')
                                 .format(to_text_string(code)
+                                .replace('\\', r'\\')
                                 .replace('"""', r'\"\"\"')))
                     self.execute_code(line)
             except AttributeError:


Test patch:
diff --git a/spyder/app/tests/script.py b/spyder/app/tests/script.py
--- a/spyder/app/tests/script.py
+++ b/spyder/app/tests/script.py
@@ -10,5 +10,5 @@
 arr = np.array(li)
 
 #%% Fourth Code/ Cell's % name\
-s = "Z:\\escape\\test\\string\n"
+s = """Z:\\escape\\test\\string\n"""
 a