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

Fix string instead of bytes-like object error. #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arenius
Copy link
Contributor

@arenius arenius commented Jan 14, 2020

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.

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.
@coveralls
Copy link

coveralls commented Jan 14, 2020

Coverage Status

Coverage remained the same at 66.826% when pulling 537493d on arenius:master into 9285ec1 on azoner:master.

@azoner
Copy link
Owner

azoner commented Jan 14, 2020

master still targets python2. The branch py3-port has all tests passing on python3. Does this error still occur on that branch?

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.

3 participants