pyx12 icon indicating copy to clipboard operation
pyx12 copied to clipboard

Fix string instead of bytes-like object error.

Open arenius opened this issue 5 years ago • 2 comments

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.

arenius avatar Jan 14 '20 22:01 arenius

Coverage Status

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

coveralls avatar Jan 14 '20 22:01 coveralls

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

azoner avatar Jan 14 '20 22:01 azoner