调试使用Python 3.6编译的_unicode错误——带有pydebug

2024-06-01 07:24:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经编译了python3.6,但是出现了一些错误,导致下面的代码失败

Python 3.6.0+ (default, Feb 25 2017, 12:10:05)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import _crypt
>>> _crypt.crypt('', '')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfb in position 1: invalid start byte

我应该在哪里调试它?你知道吗


更新:

>>> sys.path
['', 
 '/Users/andrei/Python/installed/lib/python36.zip',
 '/Users/andrei/Python/installed/lib/python3.6', 
 '/Users/andrei/Python/installed/lib/python3.6/lib-dynload', 
 '/Users/andrei/Python/installed/lib/python3.6/site-packages']

更新:

building '_crypt' extension
gcc -Wno-unused-result -Wsign-compare -g -O0 -Wall -Wstrict-prototypes -I/usr/local/opt/openssl/include -I/usr/local/opt/openssl/include -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -I./Include -I. -I/usr/local/include -I/Users/andrei/Python/cpython/Include -I/Users/andrei/Python/cpython -c /Users/andrei/Python/cpython/Modules/_cryptmodule.c -o build/temp.macosx-10.12-x86_64-3.6-pydebug/Users/andrei/Python/cpython/Modules/_cryptmodule.o
gcc -bundle -undefined dynamic_lookup -L/usr/local/opt/openssl/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/openssl/lib -I/usr/local/opt/openssl/include build/temp.macosx-10.12-x86_64-3.6-pydebug/Users/andrei/Python/cpython/Modules/_cryptmodule.o -L/usr/local/opt/openssl/lib -L/usr/local/lib -o build/lib.macosx-10.12-x86_64-3.6-pydebug/_crypt.cpython-36dm-darwin.so
building '_csv' extension

_crypt扩展看起来没有问题。。。你知道吗


更新:

$ ./python.exe -m test -j6 test_crypt
Run tests in parallel using 6 child processes
0:00:00 [1/1] test_crypt passed
1 test OK.

Total duration: 447 ms
Tests result: SUCCESS

更新:当我删除--with-pydebug时问题就消失了。你知道吗


Tags: installedintestincludelibusrlocalcpython