[Python-Dev] Error embedding python (original) (raw)

Chris Bryan cbryan at rapitasystems.com
Fri Apr 6 07:56:49 EDT 2018


Hello list,

I am embedding a python 3.6 environment in another executable, which is compiling and executing ok. However I get an error on Windows when I try to import any module except sys:

Traceback (most recent call last):   File "args", line 1, in   File "", line 971, in _find_and_load   File "", line 951, in _find_and_load_unlocked   File "", line 894, in _find_spec   File "", line 1157, in find_spec   File "", line 1129, in _get_spec   File "", line 1245, in find_spec   File "", line 1302, in _fill_cache TypeError: a bytes-like object is required, not 'str'

Looking on line 1302, it would appear that the call to _os.listdir() (line 1285) is returning a list of byte objects. I can confirm that I get the same error doing the following from a normal python interactive session:

x = b'a.b.c' x.partition('.') Traceback (most recent call last):   File "", line 1, in TypeError: a bytes-like object is required, not 'str'

Is this a bug in the bootstrap module, or am I doing something wrong which is causing listdir() to return bytes?

Chris



More information about the Python-Dev mailing list