Fix string instead of bytes-like object error.#67
Open
arenius wants to merge 1 commit intoazoner:masterfrom
Open
Fix string instead of bytes-like object error.#67arenius wants to merge 1 commit intoazoner:masterfrom
arenius wants to merge 1 commit intoazoner:masterfrom
Conversation
Running x12norm with python3 I received the following error:
Traceback (most recent call last):
File "/usr/local/bin/x12norm", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/pyx12/scripts/x12norm.py", line 71, in main
fd_out.write(seg_data.format() + eol)
TypeError: a bytes-like object is required, not 'str'
fd_out is a "tempfile.TemporaryFile()".
The tempfile docs state:
The mode parameter defaults to 'w+b' so that the file created can be read and
written without being closed. Binary mode is used so that it behaves
consistently on all platforms without regard for the data that is stored.
In other parts of the x12norm code mode 'w' is set explicitly so I think
it is okay to do so for the tempfile as well. This commit does that.
Owner
|
master still targets python2. The branch py3-port has all tests passing on python3. Does this error still occur on that branch? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Running x12norm with python3 I received the following error:
Traceback (most recent call last):
File "/usr/local/bin/x12norm", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/pyx12/scripts/x12norm.py", line 71, in main
fd_out.write(seg_data.format() + eol)
TypeError: a bytes-like object is required, not 'str'
fd_out is a "tempfile.TemporaryFile()".
The tempfile docs state:
The mode parameter defaults to 'w+b' so that the file created can be read and
written without being closed. Binary mode is used so that it behaves
consistently on all platforms without regard for the data that is stored.
In other parts of the x12norm code mode 'w' is set explicitly so I think
it is okay to do so for the tempfile as well. This commit does that.