我正在寻找标准 json 模块的更好替代品,我找到了 cjson 模块 ( https://github.com/AGProjects/python-cjson/ ),据说它是可用的最快的编码器/解码器。但是,使用 pip3 (Python 3.5) 安装它会返回以下错误(我太笨了,想不通):
object = PyString_DecodeEscape(jsondata->ptr+1, len, NULL, 0, NULL);
^~~~~~~~~~~~~~~~~~~~~ cjson.c:167:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
object = PyString_DecodeEscape(jsondata->ptr+1, len, NULL, 0, NULL);
^ cjson.c:169:18: warning: implicit declaration of function ‘PyString_FromStringAndSize’ [-Wimplicit-function-declaration]
object = PyString_FromStringAndSize(jsondata->ptr+1, len);
^~~~~~~~~~~~~~~~~~~~~~~~~~ cjson.c:169:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
object = PyString_FromStringAndSize(jsondata->ptr+1, len);
^ cjson.c:185:39: warning: implicit declaration of function ‘PyString_AsString’ [-Wimplicit-function-declaration]
reason ? PyString_AsString(reason) : "bad format");
^~~~~~~~~~~~~~~~~ cjson.c:185:65: warning: pointer/integer type mismatch in conditional expression
reason ? PyString_AsString(reason) : "bad format");
^ cjson.c: In function ‘decode_number’: cjson.c:295:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
str = PyString_FromStringAndSize(jsondata->ptr, ptr - jsondata->ptr);
^ cjson.c:300:18: error: too many arguments to function ‘PyFloat_FromString’
object = PyFloat_FromString(str, NULL);
^~~~~~~~~~~~~~~~~~ In file included from /usr/include/python3.5m/Python.h:81:0,
from cjson.c:5: /usr/include/python3.5m/floatobject.h:42:24: note: declared here PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*);
^~~~~~~~~~~~~~~~~~ cjson.c:302:18: warning: implicit declaration of function ‘PyInt_FromString’ [-Wimplicit-function-declaration]
object = PyInt_FromString(PyString_AS_STRING(str), NULL, 10);
^~~~~~~~~~~~~~~~ cjson.c:302:35: warning: implicit declaration of function ‘PyString_AS_STRING’ [-Wimplicit-function-declaration]
object = PyInt_FromString(PyString_AS_STRING(str), NULL, 10);
^~~~~~~~~~~~~~~~~~ cjson.c:302:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
object = PyInt_FromString(PyString_AS_STRING(str), NULL, 10);
^ cjson.c: In function ‘encode_string’: cjson.c:593:14: error: unknown type name ‘PyStringObject’
register PyStringObject* op = (PyStringObject*) string;
^~~~~~~~~~~~~~ cjson.c:593:36: error: ‘PyStringObject’ undeclared (first use in this function)
register PyStringObject* op = (PyStringObject*) string;
^~~~~~~~~~~~~~ cjson.c:593:36: note: each undeclared identifier is reported only once for each function it appears in cjson.c:593:51: error: expected expression before ‘)’ token
register PyStringObject* op = (PyStringObject*) string;
^ cjson.c:594:32: error: request for member ‘ob_size’ in something not a structure or union
size_t newsize = 2 + 6 * op->ob_size;
^~ cjson.c:597:11: error: request for member ‘ob_size’ in something not a structure or union
if (op->ob_size > (PY_SSIZE_T_MAX-2)/6) {
^~ cjson.c:602:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
v = PyString_FromStringAndSize((char *)NULL, newsize);
^ cjson.c:614:11: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
p = PyString_AS_STRING(v);
^ cjson.c:616:27: error: request for member ‘ob_size’ in something not a structure or union
for (i = 0; i < op->ob_size; i++) {
^~ cjson.c:620:19: error: request for member ‘ob_sval’ in something not a structure or union
c = op->ob_sval[i];
^~ cjson.c:646:9: warning: implicit declaration of function ‘_PyString_Resize’ [-Wimplicit-function-declaration]
_PyString_Resize(&v, (int) (p - PyString_AS_STRING(v)));
^~~~~~~~~~~~~~~~ cjson.c:646:30: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
_PyString_Resize(&v, (int) (p - PyString_AS_STRING(v)));
^ cjson.c: In function ‘encode_unicode’: cjson.c:697:10: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
repr = PyString_FromStringAndSize(NULL, 2 + expandsize*size + 1);
^ cjson.c:701:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
p = PyString_AS_STRING(repr);
^ cjson.c:709:57: error: subscripted value is neither array nor pointer nor vector
if ((ch == (Py_UNICODE) PyString_AS_STRING(repr)[0] || ch == '\\')) {
^ cjson.c:804:36: error: subscripted value is neither array nor pointer nor vector
*p++ = PyString_AS_STRING(repr)[0];
^ cjson.c: In function ‘encode_tuple’: cjson.c:828:10: error: ‘PyTupleObject {aka struct <anonymous>}’ has no member named ‘ob_size’; did you mean ‘ob_base’?
n = v->ob_size;
^~ cjson.c:830:16: warning: implicit declaration of function ‘PyString_FromString’ [-Wimplicit-function-declaration]
return PyString_FromString("[]");
^~~~~~~~~~~~~~~~~~~ cjson.c:830:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("[]");
^~~~~~~~~~~~~~~~~~~~~~~~~ cjson.c:846:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString("[");
^ cjson.c:850:5: warning: implicit declaration of function ‘PyString_ConcatAndDel’ [-Wimplicit-function-declaration]
PyString_ConcatAndDel(&s, temp);
^~~~~~~~~~~~~~~~~~~~~ cjson.c:855:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString("]");
^ cjson.c:865:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString(", ");
^ cjson.c:868:14: warning: implicit declaration of function ‘_PyString_Join’ [-Wimplicit-function-declaration]
result = _PyString_Join(s, pieces);
^~~~~~~~~~~~~~ cjson.c:868:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
result = _PyString_Join(s, pieces);
^ cjson.c: In function ‘encode_list’: cjson.c:902:10: error: ‘PyListObject {aka struct <anonymous>}’ has no member named ‘ob_size’; did you mean ‘ob_base’?
if (v->ob_size == 0) {
^~ cjson.c:903:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
result = PyString_FromString("[]");
^ cjson.c:913:22: error: ‘PyListObject {aka struct <anonymous>}’ has no member named ‘ob_size’; did you mean ‘ob_base’?
for (i = 0; i < v->ob_size; ++i) {
^~ cjson.c:926:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString("[");
^ cjson.c:935:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString("]");
^ cjson.c:945:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString(", ");
^ cjson.c:948:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
result = _PyString_Join(s, pieces);
^ cjson.c: In function ‘encode_dict’: cjson.c:987:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
result = PyString_FromString("{}");
^ cjson.c:995:11: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
colon = PyString_FromString(": ");
^ cjson.c:1005:14: warning: implicit declaration of function ‘PyString_Check’ [-Wimplicit-function-declaration]
if (!PyString_Check(key) && !PyUnicode_Check(key)) {
^~~~~~~~~~~~~~ cjson.c:1014:9: warning: implicit declaration of function ‘PyString_Concat’ [-Wimplicit-function-declaration]
PyString_Concat(&s, colon);
^~~~~~~~~~~~~~~ cjson.c:1027:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString("{");
^ cjson.c:1036:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString("}");
^ cjson.c:1046:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString(", ");
^ cjson.c:1049:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
result = _PyString_Join(s, pieces);
^ cjson.c: In function ‘encode_object’: cjson.c:1064:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("true");
^~~~~~~~~~~~~~~~~~~~~~~~~~~ cjson.c:1066:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("false");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~ cjson.c:1068:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("null");
^~~~~~~~~~~~~~~~~~~~~~~~~~~ cjson.c:1076:20: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("NaN");
^~~~~~~~~~~~~~~~~~~~~~~~~~ cjson.c:1079:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("Infinity");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cjson.c:1081:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("-Infinity");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cjson.c:1086:16: warning: implicit declaration of function ‘PyInt_Check’ [-Wimplicit-function-declaration]
} else if (PyInt_Check(object) || PyLong_Check(object)) {
^~~~~~~~~~~ cjson.c: In function ‘JSON_decode’: cjson.c:1149:9: warning: implicit declaration of function ‘PyString_AsStringAndSize’ [-Wimplicit-function-declaration]
if (PyString_AsStringAndSize(str, &(jsondata.str), NULL) == -1) {
^~~~~~~~~~~~~~~~~~~~~~~~ cjson.c:1155:35: warning: implicit declaration of function ‘PyString_GET_SIZE’ [-Wimplicit-function-declaration]
jsondata.end = jsondata.str + PyString_GET_SIZE(str);
^~~~~~~~~~~~~~~~~ cjson.c: In function ‘initcjson’: cjson.c:1206:9: warning: implicit declaration of function ‘Py_InitModule3’ [-Wimplicit-function-declaration]
m = Py_InitModule3("cjson", cjson_methods, module_doc);
^~~~~~~~~~~~~~ cjson.c:1206:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
m = Py_InitModule3("cjson", cjson_methods, module_doc);
^ cjson.c:1209:9: warning: ‘return’ with no value, in function returning non-void
return;
^~~~~~ cjson.c:1202:1: note: declared here initcjson(void) ^~~~~~~~~ cjson.c:1213:9: warning: ‘return’ with no value, in function returning non-void
return;
^~~~~~ cjson.c:1202:1: note: declared here initcjson(void) ^~~~~~~~~ cjson.c:1219:9: warning: ‘return’ with no value, in function returning non-void
return;
^~~~~~ cjson.c:1202:1: note: declared here initcjson(void) ^~~~~~~~~ cjson.c:1225:9: warning: ‘return’ with no value, in function returning non-void
return;
^~~~~~ cjson.c:1202:1: note: declared here initcjson(void) ^~~~~~~~~ error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
---------------------------------------- Failed building wheel for python-cjson Running setup.py clean for python-cjson Failed to build python-cjson Installing collected packages: python-cjson Running setup.py install for python-cjson ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3pu8hloy/python-cjson/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record /tmp/pip-zp1kxfa_-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
running install
running build
running build_ext
building 'cjson' extension
creating build
creating build/temp.linux-x86_64-3.5
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-7CCmgg/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DMODULE_VERSION=1.2.1 -I/usr/include/python3.5m -c cjson.c -o build/temp.linux-x86_64-3.5/cjson.o
cjson.c: In function ‘decode_string’:
cjson.c:167:18: warning: implicit declaration of function ‘PyString_DecodeEscape’ [-Wimplicit-function-declaration]
object = PyString_DecodeEscape(jsondata->ptr+1, len, NULL, 0, NULL);
^~~~~~~~~~~~~~~~~~~~~
cjson.c:167:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
object = PyString_DecodeEscape(jsondata->ptr+1, len, NULL, 0, NULL);
^
cjson.c:169:18: warning: implicit declaration of function ‘PyString_FromStringAndSize’ [-Wimplicit-function-declaration]
object = PyString_FromStringAndSize(jsondata->ptr+1, len);
^~~~~~~~~~~~~~~~~~~~~~~~~~
cjson.c:169:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
object = PyString_FromStringAndSize(jsondata->ptr+1, len);
^
cjson.c:185:39: warning: implicit declaration of function ‘PyString_AsString’ [-Wimplicit-function-declaration]
reason ? PyString_AsString(reason) : "bad format");
^~~~~~~~~~~~~~~~~
cjson.c:185:65: warning: pointer/integer type mismatch in conditional expression
reason ? PyString_AsString(reason) : "bad format");
^
cjson.c: In function ‘decode_number’:
cjson.c:295:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
str = PyString_FromStringAndSize(jsondata->ptr, ptr - jsondata->ptr);
^
cjson.c:300:18: error: too many arguments to function ‘PyFloat_FromString’
object = PyFloat_FromString(str, NULL);
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/python3.5m/Python.h:81:0,
from cjson.c:5:
/usr/include/python3.5m/floatobject.h:42:24: note: declared here
PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*);
^~~~~~~~~~~~~~~~~~
cjson.c:302:18: warning: implicit declaration of function ‘PyInt_FromString’ [-Wimplicit-function-declaration]
object = PyInt_FromString(PyString_AS_STRING(str), NULL, 10);
^~~~~~~~~~~~~~~~
cjson.c:302:35: warning: implicit declaration of function ‘PyString_AS_STRING’ [-Wimplicit-function-declaration]
object = PyInt_FromString(PyString_AS_STRING(str), NULL, 10);
^~~~~~~~~~~~~~~~~~
cjson.c:302:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
object = PyInt_FromString(PyString_AS_STRING(str), NULL, 10);
^
cjson.c: In function ‘encode_string’:
cjson.c:593:14: error: unknown type name ‘PyStringObject’
register PyStringObject* op = (PyStringObject*) string;
^~~~~~~~~~~~~~
cjson.c:593:36: error: ‘PyStringObject’ undeclared (first use in this function)
register PyStringObject* op = (PyStringObject*) string;
^~~~~~~~~~~~~~
cjson.c:593:36: note: each undeclared identifier is reported only once for each function it appears in
cjson.c:593:51: error: expected expression before ‘)’ token
register PyStringObject* op = (PyStringObject*) string;
^
cjson.c:594:32: error: request for member ‘ob_size’ in something not a structure or union
size_t newsize = 2 + 6 * op->ob_size;
^~
cjson.c:597:11: error: request for member ‘ob_size’ in something not a structure or union
if (op->ob_size > (PY_SSIZE_T_MAX-2)/6) {
^~
cjson.c:602:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
v = PyString_FromStringAndSize((char *)NULL, newsize);
^
cjson.c:614:11: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
p = PyString_AS_STRING(v);
^
cjson.c:616:27: error: request for member ‘ob_size’ in something not a structure or union
for (i = 0; i < op->ob_size; i++) {
^~
cjson.c:620:19: error: request for member ‘ob_sval’ in something not a structure or union
c = op->ob_sval[i];
^~
cjson.c:646:9: warning: implicit declaration of function ‘_PyString_Resize’ [-Wimplicit-function-declaration]
_PyString_Resize(&v, (int) (p - PyString_AS_STRING(v)));
^~~~~~~~~~~~~~~~
cjson.c:646:30: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
_PyString_Resize(&v, (int) (p - PyString_AS_STRING(v)));
^
cjson.c: In function ‘encode_unicode’:
cjson.c:697:10: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
repr = PyString_FromStringAndSize(NULL, 2 + expandsize*size + 1);
^
cjson.c:701:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
p = PyString_AS_STRING(repr);
^
cjson.c:709:57: error: subscripted value is neither array nor pointer nor vector
if ((ch == (Py_UNICODE) PyString_AS_STRING(repr)[0] || ch == '\\')) {
^
cjson.c:804:36: error: subscripted value is neither array nor pointer nor vector
*p++ = PyString_AS_STRING(repr)[0];
^
cjson.c: In function ‘encode_tuple’:
cjson.c:828:10: error: ‘PyTupleObject {aka struct <anonymous>}’ has no member named ‘ob_size’; did you mean ‘ob_base’?
n = v->ob_size;
^~
cjson.c:830:16: warning: implicit declaration of function ‘PyString_FromString’ [-Wimplicit-function-declaration]
return PyString_FromString("[]");
^~~~~~~~~~~~~~~~~~~
cjson.c:830:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("[]");
^~~~~~~~~~~~~~~~~~~~~~~~~
cjson.c:846:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString("[");
^
cjson.c:850:5: warning: implicit declaration of function ‘PyString_ConcatAndDel’ [-Wimplicit-function-declaration]
PyString_ConcatAndDel(&s, temp);
^~~~~~~~~~~~~~~~~~~~~
cjson.c:855:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString("]");
^
cjson.c:865:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString(", ");
^
cjson.c:868:14: warning: implicit declaration of function ‘_PyString_Join’ [-Wimplicit-function-declaration]
result = _PyString_Join(s, pieces);
^~~~~~~~~~~~~~
cjson.c:868:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
result = _PyString_Join(s, pieces);
^
cjson.c: In function ‘encode_list’:
cjson.c:902:10: error: ‘PyListObject {aka struct <anonymous>}’ has no member named ‘ob_size’; did you mean ‘ob_base’?
if (v->ob_size == 0) {
^~
cjson.c:903:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
result = PyString_FromString("[]");
^
cjson.c:913:22: error: ‘PyListObject {aka struct <anonymous>}’ has no member named ‘ob_size’; did you mean ‘ob_base’?
for (i = 0; i < v->ob_size; ++i) {
^~
cjson.c:926:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString("[");
^
cjson.c:935:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString("]");
^
cjson.c:945:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString(", ");
^
cjson.c:948:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
result = _PyString_Join(s, pieces);
^
cjson.c: In function ‘encode_dict’:
cjson.c:987:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
result = PyString_FromString("{}");
^
cjson.c:995:11: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
colon = PyString_FromString(": ");
^
cjson.c:1005:14: warning: implicit declaration of function ‘PyString_Check’ [-Wimplicit-function-declaration]
if (!PyString_Check(key) && !PyUnicode_Check(key)) {
^~~~~~~~~~~~~~
cjson.c:1014:9: warning: implicit declaration of function ‘PyString_Concat’ [-Wimplicit-function-declaration]
PyString_Concat(&s, colon);
^~~~~~~~~~~~~~~
cjson.c:1027:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString("{");
^
cjson.c:1036:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString("}");
^
cjson.c:1046:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
s = PyString_FromString(", ");
^
cjson.c:1049:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
result = _PyString_Join(s, pieces);
^
cjson.c: In function ‘encode_object’:
cjson.c:1064:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("true");
^~~~~~~~~~~~~~~~~~~~~~~~~~~
cjson.c:1066:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("false");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
cjson.c:1068:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("null");
^~~~~~~~~~~~~~~~~~~~~~~~~~~
cjson.c:1076:20: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("NaN");
^~~~~~~~~~~~~~~~~~~~~~~~~~
cjson.c:1079:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("Infinity");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cjson.c:1081:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PyString_FromString("-Infinity");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cjson.c:1086:16: warning: implicit declaration of function ‘PyInt_Check’ [-Wimplicit-function-declaration]
} else if (PyInt_Check(object) || PyLong_Check(object)) {
^~~~~~~~~~~
cjson.c: In function ‘JSON_decode’:
cjson.c:1149:9: warning: implicit declaration of function ‘PyString_AsStringAndSize’ [-Wimplicit-function-declaration]
if (PyString_AsStringAndSize(str, &(jsondata.str), NULL) == -1) {
^~~~~~~~~~~~~~~~~~~~~~~~
cjson.c:1155:35: warning: implicit declaration of function ‘PyString_GET_SIZE’ [-Wimplicit-function-declaration]
jsondata.end = jsondata.str + PyString_GET_SIZE(str);
^~~~~~~~~~~~~~~~~
cjson.c: In function ‘initcjson’:
cjson.c:1206:9: warning: implicit declaration of function ‘Py_InitModule3’ [-Wimplicit-function-declaration]
m = Py_InitModule3("cjson", cjson_methods, module_doc);
^~~~~~~~~~~~~~
cjson.c:1206:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
m = Py_InitModule3("cjson", cjson_methods, module_doc);
^
cjson.c:1209:9: warning: ‘return’ with no value, in function returning non-void
return;
^~~~~~
cjson.c:1202:1: note: declared here
initcjson(void)
^~~~~~~~~
cjson.c:1213:9: warning: ‘return’ with no value, in function returning non-void
return;
^~~~~~
cjson.c:1202:1: note: declared here
initcjson(void)
^~~~~~~~~
cjson.c:1219:9: warning: ‘return’ with no value, in function returning non-void
return;
^~~~~~
cjson.c:1202:1: note: declared here
initcjson(void)
^~~~~~~~~
cjson.c:1225:9: warning: ‘return’ with no value, in function returning non-void
return;
^~~~~~
cjson.c:1202:1: note: declared here
initcjson(void)
^~~~~~~~~
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
---------------------------------------- Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3pu8hloy/python-cjson/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record /tmp/pip-zp1kxfa_-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-3pu8hloy/python-cjson/
谢谢。
最佳答案
根据 py3readiness.org ,目前没有对 python-cjson 的 Python3 支持。
您可以通过pip install ujson 安装它。
关于python - 为什么我不能在 Python 3.x 中使用 python-cjson?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43565450/
我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div
我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看rubyzip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d
类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc
很好奇,就使用rubyonrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提
假设我做了一个模块如下:m=Module.newdoclassCendend三个问题:除了对m的引用之外,还有什么方法可以访问C和m中的其他内容?我可以在创建匿名模块后为其命名吗(就像我输入“module...”一样)?如何在使用完匿名模块后将其删除,使其定义的常量不再存在? 最佳答案 三个答案:是的,使用ObjectSpace.此代码使c引用你的类(class)C不引用m:c=nilObjectSpace.each_object{|obj|c=objif(Class===objandobj.name=~/::C$/)}当然这取决于
我正在尝试使用ruby和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
我有一个模型:classItem项目有一个属性“商店”基于存储的值,我希望Item对象对特定方法具有不同的行为。Rails中是否有针对此的通用设计模式?如果方法中没有大的if-else语句,这是如何干净利落地完成的? 最佳答案 通常通过Single-TableInheritance. 关于ruby-on-rails-Rails-子类化模型的设计模式是什么?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.co
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h