Repository: spyder-ide/spyder

Issue:
Problem decoding source (pyflakes E) (Spyder 4)
Image below; occurred seemingly randomly when editing code in a separate Spyder window (via "new window"); no clue how to reproduce. As is seen, commenting out the offending line doesn't help; what does: (1) commenting out entire file code; (2) causing syntax error elsewhere in code (but as soon as either is undone, error returns).

Also, when I un-commented that first line, Spyder froze and I had to restart it (after which the error's gone). I like the new features, but hope these are fixed soon as they're rather disruptive.

<hr>

![image](https://user-images.githubusercontent.com/16495490/71302877-fb50da00-23c9-11ea-9f4b-a7854c997655.png)



Discussion:
> Image below; occurred seemingly randomly when editing code in a separate Spyder window; no clue how to reproduce

You need to provide us with a reproducible use case. Otherwise, we'll be unable to solve this.

> I like the new features, but hope these are fixed soon as they're rather disruptive.

I understand your frustration, but this kind of error reports are also frustrating for us because it's more like a complaint than a proper bug report.
>this kind of error reports are also frustrating for us because it's more like a complaint than a proper bug report.

Agreed, but again they appear to simply come and go - it's rather a lose-lose situation. If I manage to find reproducible steps, will update.
@OverLordGoldDragon What you have shown are imports without how they are used or where they came from.  Can you reproduce the symptoms that you described in a smaller program with fewer external import dependencies? A source file that can be compiled by Python 3 or analyzed by pylint by other people would facilitate investigation.
@OverLordGoldDragon, I was also thinking about this yesterday, and it could be related to using an encoding different than `utf-8` in the files you opened in Spyder's editor.

Is that the case with the file you shown above?
@ccordoba12 I haven't pasted anything into the `.py` files, which I typed from scratch, and haven't tweaked encoding options. Regardless, how would I view what encoding a `.py` file uses?

@texadactyl `model_utils` imports from `keras` or `tensorflow.keras` depending on the `os.environ["TF_KERAS"]` flag - I'll see if I can narrow it down next time it occurs
> I haven't pasted anything into the .py files, which I typed from scratch

Did you write them entirely in Spyder?

> Regardless, how would I view what encoding a .py file uses?

It's shown in the status bar:

![Selección_069](https://user-images.githubusercontent.com/365293/71416310-db215500-262d-11ea-8fb5-48a0528bcfc7.png)

In this case, the file has the UTF-8 encoding.
> Did you write them entirely in Spyder?

Cannot guarantee I never pasted a single character from elsewhere, no - but vast majority is indeed typed in Spyder

And... bingo, you may be onto something:

![image](https://user-images.githubusercontent.com/16495490/71418004-ccfd2400-2681-11ea-8396-5570a1008c8a.png)

I haven't had this specific problem recur ever since, but in case encoding is important for some other bugs or general stability - how do I swap to UTF-8?

You need to add this comment

```python
# -*- coding: utf-8 -*-
```

to the top of your files (i.e. it needs to be the first line in them).
@ccordoba12 I think even add ```# -*- coding: utf-8 -*-``` doesn't help. I had the same issue. When I create a new file, the error icon occurs exactly like above. @OverLordGoldDragon The way I solve this problem is to close the file and reopen the same script. Then the icon is gone.
I do not think we are changing the encoding on the fly with just adding that line, that is why the reopen is necessary. Other IDEs provide the option to change the encoding with a menu entry. We could also provide thus by making the status bar item clickable (which would display enconding options with a menu/dropdown)
Had this problem today. Restarting spyder fixed it. 
To notify, I've never had this problem since - though I've been using `# -*- coding: utf-8 -*-` atop each file.
@OverLordGoldDragon, could you please provide us with a minimum reproducible file that presents this issue?
@andfoy Unsure, the behavior is spontaneous - I was just editing a file and it popped up. There is no file that has this marking upon simply opening it. Maybe there's a 'trigger' though - it happened after linter marked a Syntax error which I resolved; I'll notify if I find anything.

Resolving patch:
diff --git a/spyder/plugins/completion/languageserver/client.py b/spyder/plugins/completion/languageserver/client.py
--- a/spyder/plugins/completion/languageserver/client.py
+++ b/spyder/plugins/completion/languageserver/client.py
@@ -166,7 +166,11 @@ def start(self):
         self.transport_args += ['--zmq-in-port', self.zmq_out_port,
                                 '--zmq-out-port', self.zmq_in_port]
 
-        server_log = subprocess.PIPE
+        # The server stdout needs to be set to 'None' by default on Windows
+        # to correctly handle errors that come from the server.
+        # Fixes spyder-ide/spyder#11506
+        server_log = None if os.name == 'nt' else subprocess.PIPE
+
         pid = os.getpid()
         if get_debug_level() > 0:
             # Create server log file


Test patch: