Python

Python

Python

 View Only
  • 1.  Using Python with JCL & Rexx

    Posted Wed October 02, 2024 03:00 PM

    Hello,

    I hope you are well.

    I have Python 3.12 and ZOAU 1.3.1 installed on my Z/OS and I read the tutorial "Using Python with JCL & Rexx - IBM Z and LinuxONE Community".

    I tested the different examples.

    For the first example (hello.py + pyjob.jcl), I had no issues.

    My problem occurred when I launched the second part (dd.py + pyjob.jcl) with the file IBMUSER.JCL.DEMO.DD.

    I received an RC=256 and the message: SyntaxError: Non-UTF-8 code starting with '\xb1' in file /u/ibmuser/jcl/dd.py on line 1, but no encoding declared; see https://peps.python.org/pep-0263/ for details.

    I tried to put # -*- coding: utf-8 -*- at the beginning of the file, but I still have the same issue.

    Do you know how I can solve this encoding issue?

    Best regards,
    Bruno LAURENT



    ------------------------------
    Bruno LAURENT
    ------------------------------


  • 2.  RE: Using Python with JCL & Rexx

    Posted Wed October 02, 2024 05:01 PM

    Hi Bruno. This type of error is usually due to the wrong encoding being used, or having the file being tagged with the wrong encoding. We recommend that you encode & tag your scripts with either IBM-1047 or ISO8859-1. Would you be able to verify the following:

    1) That the file contains either text encoded in IBM-1047 or ISO8859-1? 

    2) That the file is tagged with the correct encoding that reflects IBM-1047 or ISO8859-1?

    The simplest way to do these is to run the following commands:

    ls -T dd.py

    This will output what the file is tagged as (binary, untagged, IBM-1047, ISO8859-1). To tag the file with the encoding you expect, you can run one of the following to change the file tag to a given encoding.

    chtag -tc IBM-1047 dd.py   # Change the file tagging to IBM-1047
    chtag -tc ISO8859-1 dd.py   # Change the file tagging to ISO8859-1

    After the file is tagged with the correct encoding, you can simply try to read the file to confirm:

    _BPXK_AUTOCVT=ON cat dd.py

    If there are any corrupted characters, then the file does not contain that encoding and needs to be addressed.

    If you follow all of those steps and do not see any corrupted characters, could you provide us some information:

    1) The output to running ls -T dd.py

    2) The output to running _BPXK_AUTOCVT=ON cat dd.py

    3) The version of Python that you're currently using, which can be obtained by running python3 --version

    Thanks



    ------------------------------
    Steven Pitman
    ------------------------------



  • 3.  RE: Using Python with JCL & Rexx

    Posted Sun October 06, 2024 05:42 AM
    Edited by Denis FALLAI Sun October 06, 2024 05:45 AM

    Hi,

    Be carrefull with your 3270 terminal emulator : if you want to edit an IBM-1047 encoded file you should configure your 3270 terminal emulator with IBM-1047. 

    File tagging is not sufficient. It declare encoded used, it does not convert or impose encoding during editing.



    ------------------------------
    Denis FALLAI
    BPCE SI, BPCE group.
    ------------------------------