Giter VIP home page Giter VIP logo

Comments (4)

victor-roy avatar victor-roy commented on July 30, 2024

Which line in which source file is throwing the error? Can you post the full traceback?

from pyx12.

jasirmuhammad avatar jasirmuhammad commented on July 30, 2024

@victor-roy
ERROR Failed to create 999 response
Traceback (most recent call last):
File "c:\python\python37-32\lib\site-packages\pyx12\x12n_document.py", line 252, in x12n_document
errh.accept(visit_999)
File "c:\python\python37-32\lib\site-packages\pyx12\error_handler.py", line 101, in accept
visitor.visit_root_pre(self)
File "c:\python\python37-32\lib\site-packages\pyx12\error_999.py", line 83, in visit_root_pre
self.wr.Write(isa_seg)
File "c:\python\python37-32\lib\site-packages\pyx12\x12file.py", line 495, in Write
self._write_isa_segment(seg_data)
File "c:\python\python37-32\lib\site-packages\pyx12\x12file.py", line 582, in _write_isa_segment
self.fd_out.write(out)
File "C:\Python\Python37-32\Lib\tempfile.py", line 481, in func_wrapper
return func(*args, **kwargs)
TypeError: a bytes-like object is required, not 'str'

from pyx12.

ddw360 avatar ddw360 commented on July 30, 2024

@azoner, @victor-roy

Using Python3 v3.8.5 on Windows... when running x12valid.py (v2.3.3) specifically, down stack in x12file.py, any line with:
self.fd_out.write(out) results in "TypeError: a bytes-like object is required, not 'str'".

Hack to force self.fd_out.write(bytes(out, encoding='ascii')) opens up a can of worms in downstream processing as there is bytes to string conversion needed if the hack is applied - so that is not the simple fix.

I am still debugging - but I assume that wherever x12valid.py code calls x12file.X12Writer - the "src_file_obj" needs to have the correct mode as tempfile._TemporaryFileWrapper. If anyone who knows the code base better can suggest the quick fix, I can try it and apply and do a pull request. Otherwise, given extra time (aka boredeom) and/or an urgent need to get x12valid working - hopefully can figure it out.

from pyx12.

ddw360 avatar ddw360 commented on July 30, 2024

@azoner, @victor-roy , @jasirmuhammad

In x12valid.py, making this change:
- fd_997 = tempfile.TemporaryFile()
+ fd_997 = tempfile.TemporaryFile(mode='r+')
seems to work.

from pyx12.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.