question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(Python) Syntax highlighting bug in Python REPL

See original GitHub issue

Describe the issue

While posting an answer on Stack Overflow, I noticed a syntax highlighting bug in the code block showing my Python program in a REPL environment. I posted the issue on Stack Exchange Meta here which shows the bug clearly.

Which language seems to have the issue?

Python.

Are you using highlight or highlightAuto?

I am using Stack Overflow highlighting with an explicit python tag.

Sample Code to Reproduce

>>> class A:
...     @classmethod
...     def f(cls): return 'A.f'
... 
>>> class B(A):
...     @classmethod
...     def f(cls): return 'B.f'
... 
>>> b = B()
>>> b.f
<bound method B.f of <class '__main__.B'>>
>>> B.f
<bound method B.f of <class '__main__.B'>>
>>> b.f()
'B.f'
>>> B.f()
'B.f'
>>> super(B, b).f
<bound method A.f of <class '__main__.B'>>
>>> super(B, B).f
<bound method A.f of <class '__main__.B'>>
>>> super(B, b).f()
'A.f'
>>> super(B, B).f()
'A.f'

Expected behavior

Additional context

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
verhovskycommented, May 8, 2021

I think what is happening here is the quotes around the class name or the <> in the output is messing up the rest of the output. Compare highlight.js on SO

Screen Shot 2021-05-08 at 01 19 49

with the highlighter used by GitHub

Screen Shot 2021-05-08 at 01 22 08

All that stuff shouldn’t be orange. I just ran into what looks to be the same bug here https://stackoverflow.com/a/3560349

0reactions
joshgoebelcommented, May 9, 2021

Our developer tool is great (and what I was snapping) but it’s not just laying around online unfortunately. Perhaps in the future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML syntax highlighting bug? - Replit
html file within my linked Repl. A decent sized block of the HTML code towards the bottom of the file has the grey...
Read more >
Syntax highlighting language request: Python REPL
Highlight.js treats Python REPL (the Python interpreter in interactive mode) as its own language separate from Python—it uses the class ...
Read more >
Python REPL with syntax highlighting, autocomplete and ...
So I wrote a small function to just invoke the editor with the lines in the current prompt 'buffer'[1]. This gives all the...
Read more >
Broken Python syntax highlighting when raw strings ... - GitLab
Summary Syntax highlighting fails after a Python raw string is encountered. All the subsequent code is wrongly displayed as a string....
Read more >
strange issue for python syntax highlight in emacs
python.el highlihghts left hand side of assignment in a different color. It is known that it does not work with complex ones [1]....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found