[Python-Dev] Error embedding python (original) (raw)
Brett Cannon brett at python.org
Sat Apr 7 14:02:20 EDT 2018
- Previous message (by thread): [Python-Dev] Error embedding python
- Next message (by thread): [Python-Dev] Can't open standard streams with "a"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Most likely your 'args' module is calling import with a bytes object and not a string and that it's getting that far into the process before you hit code that only works with strings (_os.listdir() returns bytes if you pass a bytes argument to it).
At this point I would take the question to python-list or python-tutor to get more help with embedding.
On Fri, 6 Apr 2018 at 10:29 Chris Bryan <cbryan at rapitasystems.com> wrote:
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 findandload File "", line 951, in findandloadunlocked File "", line 894, in findspec File "", line 1157, in findspec File "", line 1129, in getspec File "", line 1245, in findspec File "", line 1302, in fillcache 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
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/brett%40python.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180407/d68d6331/attachment.html>
- Previous message (by thread): [Python-Dev] Error embedding python
- Next message (by thread): [Python-Dev] Can't open standard streams with "a"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]