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.

Issue on Python 3.6

See original GitHub issue

Code works perfectly on Python 2.7, but in Python 3.6 crashes the first time Screen.refresh() is called.

Traceback (most recent call last):
  File "/Users/anthonyshaw/repo/retox-2/retox/__main__.py", line 66, in main
    screen.refresh()
  File "/Users/anthonyshaw/repo/retox-2/src/asciimatics/asciimatics/screen.py", line 2129, in refresh
    super(_CursesScreen, self).refresh()
  File "/Users/anthonyshaw/repo/retox-2/src/asciimatics/asciimatics/screen.py", line 1216, in refresh
    self._change_colours(new_cell[1], new_cell[2], new_cell[3])
  File "/Users/anthonyshaw/repo/retox-2/src/asciimatics/asciimatics/screen.py", line 2225, in _change_colours
    self._safe_write(self._a_normal)
  File "/Users/anthonyshaw/repo/retox-2/src/asciimatics/asciimatics/screen.py", line 2085, in _safe_write
    sys.stdout.write(msg)
  File "/Users/anthonyshaw/repo/retox-2/bin/../lib/python3.6/codecs.py", line 377, in write
    self.stream.write(data)
  File "/Users/anthonyshaw/repo/retox-2/bin/../lib/python3.6/codecs.py", line 376, in write
    data, consumed = self.encode(object, self.errors)
TypeError: utf_8_encode() argument 1 must be str, not bytes

Any help/tips on debugging would be appreciated.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
peterbrittaincommented, Dec 29, 2017

Yeah - it’s doing its best to scuttle away and hide!

0reactions
peterbrittaincommented, Jan 2, 2018

Note that the problem is that tox is setting up UTF-8 StreamWriter around a UTF-8 TextIOWrapper. Getting access to the underlying BufferedWriter instead would fix the issue. For example:

sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer)
Read more comments on GitHub >

github_iconTop Results From Across the Web

It's time to stop using Python 3.6
Python 3.6 will stop getting security updates in December 2021. Given the existence of 3.7, 3.8, 3.9, and 3.10, you really should upgrade....
Read more >
Python Release Python 3.6.0
Python 3.6.0. Release Date: Dec. 23, 2016. Note: The release you are looking at is Python 3.6.0, the initial feature release for the...
Read more >
How to resolve this import error in Python 3.6? - Stack Overflow
I have the same problem. This kind of import problem happens only on python 3.6.x . Same code working on 3.7, fails in...
Read more >
Tensorflow problem in Python 3.6 · Issue #43000 - GitHub
Hi, I have installed these packages, pip list, but python 3.6 tells me it takes tensorflow 2.2 or higher, but here it is...
Read more >
Problem Solving with Python 3.6 Edition: A beginner's guide to ...
Problem Solving with Python 3.6 Edition: A beginner's guide to Python & open-source programming tools [Kazarinoff, Peter D.] on Amazon.com.
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