Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change stdout.write to stdout.buffer.write #186

Merged
merged 2 commits into from
Oct 16, 2019
Merged

Conversation

shokada
Copy link
Contributor

@shokada shokada commented Oct 11, 2019

I found the following error when using promgen rules.

$ promgen rules
Traceback (most recent call last):
  File "/Users/shokada/src/line/promgenenv/bin/promgen", line 11, in <module>
    load_entry_point('promgen', 'console_scripts', 'promgen')()
  File "/Users/shokada/src/line/promgen/promgen/manage.py", line 20, in main
    execute_from_command_line(sys.argv)
  File "/Users/shokada/src/line/promgenenv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/Users/shokada/src/line/promgenenv/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/shokada/src/line/promgenenv/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/shokada/src/line/promgenenv/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/Users/shokada/src/line/promgen/promgen/management/commands/rules.py", line 31, in handle
    self.stdout.write(prometheus.render_rules())
  File "/Users/shokada/src/line/promgenenv/lib/python3.7/site-packages/django/core/management/base.py", line 145, in write
    self._out.write(style_func(msg))
TypeError: write() argument must be str, not bytes

The cause of this error is that Command.handle in rules.py uses stdout.write even though prometheus.render_rules returns a byte string.
To avoid this, I changed stdout.write to stdout.buffer.write.

Thanks.

@CLAassistant
Copy link

CLAassistant commented Oct 11, 2019

CLA assistant check
All committers have signed the CLA.

@codecov-io
Copy link

codecov-io commented Oct 11, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@df2efa6). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #186   +/-   ##
=========================================
  Coverage          ?   47.26%           
=========================================
  Files             ?       43           
  Lines             ?     2435           
  Branches          ?        0           
=========================================
  Hits              ?     1151           
  Misses            ?     1284           
  Partials          ?        0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update df2efa6...3414e59. Read the comment docs.

@kfdm kfdm self-requested a review October 16, 2019 07:43
@kfdm kfdm merged commit 0ab964d into line:master Oct 16, 2019
@kfdm
Copy link
Collaborator

kfdm commented Oct 16, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants