Giter Site home page Giter Site logo

Python 3 and iToolkit error about python-itoolkit HOT 7 CLOSED

ibm avatar ibm commented on May 30, 2024
Python 3 and iToolkit error

from python-itoolkit.

Comments (7)

kadler avatar kadler commented on May 30, 2024

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


Great. Thanks for testing.

from python-itoolkit.

kadler avatar kadler commented on May 30, 2024

Original comment by Siegfried (Bitbucket: zipperlemeran, GitHub: Unknown).


Hello Tony,
yes I installed the new itoolkit 1.3 and it works.
Thousand thanks for you effort.
Mille grazie

Siegfried

from python-itoolkit.

kadler avatar kadler commented on May 30, 2024

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


python3-itoolkit - change iLibCall - fix UnicodeDecodeError

YIPs python3-itoolkit-1.3.zip - change iLibCall - fix UnicodeDecodeError: ascii codec cannot decode byte 0xc3

Please download fix 1.3 and install with pip3 (above). Let us know if it works for you.

from python-itoolkit.

kadler avatar kadler commented on May 30, 2024

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


python3-itoolkit - change iLibCall - fix UnicodeDecodeError

Ok, I have a new wheel on Yips for download.

Works latin-1 or utf-8 test

latin-1

#!bash
bash-4.3$ python3 italy-latin-1.py 
<?xml version="1.0" ?><xmlservice><fake>non � domani</fake></xmlservice>
#!python

# -*- coding: latin-1 -*-
from itoolkit import iToolKit
from itoolkit import iXml
from itoolkit.lib.ilibcall import iLibCall
itransport = iLibCall("*here *cdata") # *debug i will stop, inquiry message qsysopr
itool = iToolKit()
#itool.add(iXml("it's not tomorrow"))
itool.add(iXml('<fake>non è domani</fake>')) # latin-1
itool.call(itransport)
print(itool.xml_out())

utf-8

#!bash

bash-4.3$ python3 italy-utf-8.py   
<?xml version="1.0" ?><xmlservice><fake>non � domani</fake></xmlservice>
#!python

# -*- coding: utf-8 -*-
from itoolkit import iToolKit
from itoolkit import iXml
from itoolkit.lib.ilibcall import iLibCall
itransport = iLibCall("*here *cdata") # *debug i will stop, inquiry message qsysopr
itool = iToolKit()
# itool.add(iXml('<fake>non è domani</fake>')) # latin-1
itool.add(iXml('<fake>non \u00E8 domani</fake>')) # utf-8
itool.call(itransport)
print(itool.xml_out())

from python-itoolkit.

kadler avatar kadler commented on May 30, 2024

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3

Mm, python-itoolkit iLibCall may be able make a change to help. That is, experimenting with python 2 (works) vs. python 3 (not work), we think changing c-code for iLibCall may help.

#!bash

bash-4.3$ python italy.py ... ok
<?xml version="1.0" ?><xmlservice><fake>non \u00E8 domani</fake></xmlservice>


bash-4.3$ python3 italy.py ... bad
Traceback (most recent call last):
  File "italy.py", line 16, in <module>
  File "/QOpenSys/QIBM/ProdData/OPS/Python3.4/lib/python3.4/site-packages/itoolkit/itoolkit.py", line 1098, in call
    xml_out = itrans.call(self)
  File "/QOpenSys/QIBM/ProdData/OPS/Python3.4/lib/python3.4/site-packages/itoolkit/lib/ilibcall.py", line 88, in call
    return itoolkit.itoollib.xmlservice(itool.xml_in(),self.ctl,self.ipc,self.ebcdic_ccsid,self.pase_ccsid)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 44: ordinal not in range(128)


bash-4.3$ cat italy.py 
# -*- coding: utf-8 -*-
:
itool.add(iXml('<fake>non \u00E8 domani</fake>')) # utf-8
:

So, I will attempt modify c code (itoollib.so), and build a new wheel (egg). I can post the 'test wheel fix' on Yips (soon).

Will you be willing to test in your environment?

iDb2Call (ibm_db python)

I did not check null user/password.

from python-itoolkit.

kadler avatar kadler commented on May 30, 2024

Original comment by Siegfried (Bitbucket: zipperlemeran, GitHub: Unknown).


Hello Tony,
thank you for the answer.
The only solution that works is using idb2call(). Any other try throws the same error mentioned above.
But with idb2Call() there must be passed a user id and a password. Passing a generic user id like QPGMR I get the wrong job attributes for user X. Is there any possibility to use the current user id for iTransport?

Thank you
Siegfried

from python-itoolkit.

kadler avatar kadler commented on May 30, 2024

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


UnicodeDecodeError: 'ascii' codec ... /lib/ilibcall.py", line 88, in call return

You may have to try these things one at a time. We are faced with a daunting ebcdic task as IBM i has not allowed a unicode job description (cough, just sayin' ... whining he did)

Note: Depending on shell following env settings have different built-ins for 'export'. Assuming modern shell like bash 'export' works. I cannot recall qp2term (evil death of all joy green screen abomination qp2term ... not that i have opinion).

#!bash

> export LANG=it_IT
> export CCSID=1208

  1. env.txt - You have confusing LANG settings, possibly inherited shell settings. We see both generic ascii LANG=C (active) and Italian PASE_LANG=it_IT (not active).
#!bash

export LANG=it_IT
  1. env.txt - switch to UTF-8 pase ccsid (CCSID=1208). Your env has QIBM_PASE_CCSID=819 and CCSID=819. Python 3 loves UTF-8 (1208) ... and ... nothing else ... nothing else ... nothing else. Cough, you could try python 2 with more liberal view of NLS (did i say that out loud?).
#!bash
export CCSID=1208 

Try new things ...

  1. Switch to iDB2Call transport. DB2 implicit convert ascii/ebcdic (no human fumbling). This may be you best option.
#!python
      from itoolkit.db2.idb2call import *
      itransport = iDB2Call(user,password)

Try old things a new way ...

  1. Try override ccsid in iLibCall (your current memory transport)
#!python

iLibCall(ictl="*here", ipc="*na", iccsid="?ebcdic italian?", pccsid=1208)

from python-itoolkit.

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.