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 https://confluence.jetbrains.com/display/PYH/Creating+and+running+a+Python+unit+test,  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

 

 

6 comments

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: https://en.wikipedia.org/wiki/Non-breaking_space

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.

 

0

But I merely followed the instructions on your (JetBrain's) own tutorial page, which, when you mouse-hover over the sample code for solver.py, 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.

0

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.

0

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? 

0

@Ozzy

Your problem seems to be the same as https://youtrack.jetbrains.com/issue/JBR-1311

Check description for possible workarounds.

0

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

0

Please sign in to leave a comment.