osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] Error embedding python


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 <module>
 ? File "<frozen importlib._bootstrap>", line 971, in _find_and_load
 ? File "<frozen importlib._bootstrap>", line 951, in 
_find_and_load_unlocked
 ? File "<frozen importlib._bootstrap>", line 894, in _find_spec
 ? File "<frozen importlib._bootstrap_external>", line 1157, in find_spec
 ? File "<frozen importlib._bootstrap_external>", line 1129, in _get_spec
 ? File "<frozen importlib._bootstrap_external>", line 1245, in find_spec
 ? File "<frozen importlib._bootstrap_external>", 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 "<stdin>", line 1, in <module>
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