PyCharm numerous BAD_CHARACTER errors after paste operation

In PyCharm 2018.3.4, whenver I paste code samples, such as the solver class in the JetBrains PyCharm tutorial located at,  every line of code is flagged with the following error:


Statement expected, found BAD_CHARACTER

It turns out that manually typing in the code is faster than dealing with the mess that PyCharm makes of code that is pasted into its editor.

Please, JetBrains, fix this annoying bug.

PyCharm 2018.3.4 (Professional Edition)
Build #PY-183.5429.31, built on January 29, 2019
JRE: 1.8.0_152-release-1343-b26 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0




Frederick, I've replied you in the support ticket, but will also duplicate the information here for others.

Those BAD_CHARACTERs are non-breaking spaces:

I'm not sure why your copied text resulted in having them instead of normal spaces, possibly some encoding issue.

This is not IDE issue. You will also get an error if you run a code with non-breaking spaces using Python interpreter directly.



But I merely followed the instructions on your (JetBrain's) own tutorial page, which, when you mouse-hover over the sample code for, it says:

"Hint: double-click to select code"

I did exactly that and then attempted to copy/paste the sample code from that tutorial which results in the error that started this issue in the first place.

Suggestion: either stop providing the (provably useless "hint" during mouse-hover) or make a Paste Clean option in PyCharm that will "clean off/strip" the non-breaking space characters you mentioned in your initial reply.


Yes, you are right, if I copy the code using double-click, I can reproduce the issue. But this is a site issue, and the simple workaround would be to select the code by dragging mouse. The text will be copied normally then.


I'm stucked with my code. 

When typing () or '',  my code have return a BAD_CHARACTER warning. 

I don't know what is this problem.

More, I'm not have this problem before. 

Some suggestions? 



Your problem seems to be the same as

Check description for possible workarounds.


Thanks for orientation, Sergey Karpov. It's help me a lot!!!


Please sign in to leave a comment.