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.

sys.stdout.buffer is readonly withon python3.8 and newer

See original GitHub issue

Steps/Code to Reproduce

Run tests with python3.8

__________________________ test_cli_writes_to_stdout ___________________________
test/test_wordcloud_cli.py:165: in test_cli_writes_to_stdout
    sys.stdout.buffer = tmp_image_file.open('wb+')
E   AttributeError: readonly attribute

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Mic92commented, Dec 29, 2020

We should probably use the redirect_stdout context: docs.python.org/3.8/library/contextlib.html#contextlib.redirect_stdout

do you want to send a PR?

seems to break in a different way 😃

====================================================================================== FAILURES ======================================================================================
_____________________________________________________________________________ test_cli_writes_to_stdout ______________________________________________________________________________
test/test_wordcloud_cli.py:166: in test_cli_writes_to_stdout
    args, text, image_file = cli.parse_args(['--text', str(tmp_text_file)])
wordcloud/wordcloud_cli.py:225: in parse_args
    args = parser.parse_args(arguments)
/nix/store/m7080pw0ryjk0jhljp55rq1hd2qy8gki-python3-3.8.6/lib/python3.8/argparse.py:1768: in parse_args
    args, argv = self.parse_known_args(args, namespace)
/nix/store/m7080pw0ryjk0jhljp55rq1hd2qy8gki-python3-3.8.6/lib/python3.8/argparse.py:1800: in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
/nix/store/m7080pw0ryjk0jhljp55rq1hd2qy8gki-python3-3.8.6/lib/python3.8/argparse.py:2031: in _parse_known_args
    self._get_value(action, action.default))
/nix/store/m7080pw0ryjk0jhljp55rq1hd2qy8gki-python3-3.8.6/lib/python3.8/argparse.py:2422: in _get_value
    result = type_func(arg_string)
wordcloud/wordcloud_cli.py:57: in __call__
    return sys.stdout.buffer if 'b' in self._mode else sys.stdout
E   AttributeError: '_io.BufferedRandom' object has no attribute 'buffer'
0reactions
Mic92commented, Dec 30, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Python standard idiom to set sys.stdout buffer to zero doesn't ...
But first it has to be in perfect Unicode internally. Now that all works fine in general, just not with a zero byte...
Read more >
sys — System-specific parameters and functions — Python ...
This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter.
Read more >
if_pyth.txt - Vim
Use python-buffer objects to access to buffer-local options and python-window objects to access to window-local options. Type of this object is available via...
Read more >
An Introduction to the Python Buffer Protocol
Using the buffer protocol, we can let multiple objects efficiently manipulate views of the same data buffers, without having to make copies of ......
Read more >
Reference — prompt_toolkit 3.0.36 documentation
If at some point, we have Python 3.11 as the minimum supported Python version, ... raise an EditReadOnlyBuffer exception, even when the buffer...
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