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.

EventWriter is writing bytes on stdout which is not supported in python3

See original GitHub issue

Python sys.stdout.write() does not supporting writing bytes to stdout stream In event_writer.py self._out.write(b"<stream>") at line 54 and self._out.write(b"</stream>") at line 81 In event_writer.py write_xml_document method try to write encoded xml document to stream with self._out.write(ET.tostring(document)) In event.py self._out.write(ET.tostring(document)) in write_to method

This causes ERROR in modular input ingesting event like below: TypeError: write() argument must be str, not bytes

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
schneewecommented, Nov 5, 2019

You can also use this change (works for me): self._out.write(ET.tostring(document)) to self._out.write(ET.tostring(document).decode())

0reactions
ashah-splunkcommented, Aug 19, 2021

Latest release of python sdk supports Python3 along with Python2, so we would request you to use the latest version of python sdk

In the latest version, before writing the encoded XML document to stream, it is encoded through “ensure_str()” which handles the decoding of bytes before encoding the xml document while using Python3

Do let us know if the issue is resolved .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python 3 TypeError: must be str, not bytes with sys.stdout.write()
In your specific piece of code, nextline is of type bytes , not str , reading stdout and stdin from subprocess changed in...
Read more >
Issue 18512: sys.stdout.write does not allow bytes in Python 3.x
and writing to stdout were OK in Python2, which makes porting programs harder. A workaround is to perform sys. stdout. flush() before sys....
Read more >
A primer on the str and bytes types in Python 3 - arp242.net
In your specific piece of code, nextline is of type bytes , not str , reading stdout and stdin from subprocess changed in...
Read more >
Python - Write Bytes to File - GeeksforGeeks
Next, use the write function to write the byte contents to a binary file. Python3. Python3 ...
Read more >
[reportlab-users] Writing to stdout - Google Groups
I'm trying to write to stdout and it's not working. I'm using Python 3.8.6 with a clean virtualenv ... TypeError: write() argument must...
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