Products Resources Support About Us

Quandry regarding u2py.Dynarray


From the XDEMO account in UniVerse 11.3.1 running on Red Hat Enterprise Linux Server release 7.4, after starting Python and importing u2py, getting the following…

Welcome to the XDEMO Account
Version: 3.1.0

1 XDEMO From daveh-aws
python> import u2py
python> help(u2py.Dynarray)
Traceback (most recent call last):
File “”, line 1, in
AttributeError: ‘module’ object has no attribute ‘Dynarray’

Not sure what to do. Help requested. Thanks,

Dave Howell

P.S. the to_list() works with my Windows UVPE.


Try ‘help(u2py.DynArray)’ — the case of the object matters


Michael, thanks for pointing out the typo – forest and trees sometimes huh? So, “help(u2py.DynArray)” worked. Now, I find a problem with its to_list() method…

I have a ‘driver’ basic program that calls a ‘’ module with a ‘test_call’ function. The driver and python module are as follows:


module_name = “pytest”
function_name = ‘test_call’

x = “TEMP”
x<2> = ""
x<3> = “3363237692”
print 'passing in x value: ':x
pyresult = PyCallFunction(module_name, function_name, x)
CRT “py call successfull”

import u2py
def test_call(i_list):
    print('In pytest: received i_list:' + i_list)
    print('converting i_list to a python list')
    pylist = u2py.DynArray(i_list).to_list()
    print('pylist: {}'.format(pylist))
    print('pylist length is: {}'.format(len(pylist)))
    print('pylist type is: {}'.format(type(pylist)))


02 run util.uvs driver
passing in x value: TEMP▒▒3363237692
In pytest: received i_list:TEMP��3363237692
converting i_list to a python list
pylist: [‘TEMP��3363237692’]
pylist length is: 1
pylist type is: <class ‘list’>
py call successfull

Beside the delimiter marks that don’t copy well from a terminal session, you will notice that the to_list() function is not splitting the i_list dynamic array as evidenced by the length being 1 and the value of pylist is still a single dynamic array string.

I’m probably doing something stupid again, but for the life of me I can’t see what.



P.S. The to_list() method works with my Windows UVPE.


Interesting, I think I see the issue. What is you encoding.

Note easiest way to tell is
import sys

it is at the bottom


Note while I am still looking into this to determine how this occurs, it seems, like I mentioned in my previous post, that the encoding is off. I found that in some cases when python can not determine the encoding, it defaults to ANSI_X3.4-1968.

Good thing is that you can workaround this issue by setting the environment variable


Note in my testing, I stopped and started the database with the parameter set, as well as having it set for the user.


Ok. So, I set the environment variables as directed for both the database and user as evidenced by the ‘env’ cli output:

SSH_CLIENT= 61821 22

Running the driver program produces the following:

run util.uvs driver
passing in x value: TEMP▒▒3363237692
EXCEPTION TYPE IS UnicodeEncodeError
EXCEPTION MESSAGE IS ‘latin-1’ codec can’t encode character ‘\ufffd’ in position 31: ordinal not in range(256)
EXCEPTIONTRACEBACK IS Traceback (most recent call last):

File “/uvfs/ma.accounts/dvh/pymodules/”, line 5, in test_call
print(‘In pytest: received i_list:’ + i_list)

UnicodeEncodeError: ‘latin-1’ codec can’t encode character ‘\ufffd’ in position 31: ordinal not in range(256)

I also realized that I neglected to inform that NLS is enabled on the Linux install, but not on my UVPE. Might that have something to do with it?

I also saw in the “U2 Python User Guide” the following reference:

the u2py module, a property config.encoding is added, the value of which is set
by default to the current operating system’s input and output encoding. In most cases, the property
will work as intended, but it is also programmatically changeable. So if the property does not match
the native encoding the U2 engine is using and causes issues for the Python applications, the Python
application developer can always change it.

I would try to change the config.encoding, but don’t know how and possible what to change it to.

Thanks again.


Created a case, and will work with you and Engineering on this issue. Once I have an answer, I will come back an update this forum post.


Very well sir. Thanks for your help.


Michael, still no luck with the environment variable setting. However, I haven’t had much to troubleshoot further – other priorities taking precedence; one of which is getting python-kafka to work with UV Basic, which have have been successful with. We are passing parameters between UV programs and Python functions using json instead of dynamic arrays. This more approximates the way our web services work. That being said. At some point I intend to return to troubleshooting this issue. IPlease do what you must with the open case. If need be I can open another. Was the engineering fix put in place?


I have been experimenting with the passing of dynamic arrays from BASIC to python.
We do use NLS, so I’m not sure if what I have encountered is NLS specific or not.

As of it is still not possible to send a normal BASIC Dynamic Array to python and then create a u2py.DynArray() object using it.

This is because the system delimiters (@AM, @VM, …) all get converted to \Ufffd.

Looking at this character in Unicode gives us a hint:

In Unicode this is the “replacement” character for unknown characters, so the UV-to-python string conversion is not properly dealing with the system delimiters.

Your approach of using JSON seems to be the next best way to marshal the data between the 2 execution environments.