[
https://issues.apache.org/jira/browse/ARROW-2347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16417526#comment-16417526
]
Antoine Pitrou commented on ARROW-2347:
---------------------------------------
> Hm, are there other solutions to the enum signedness issue?
I'm not sure. It seems Cython is generating that code precisely to know whether
the enum is signed:
{code:c}
static CYTHON_INLINE PyObject*
__Pyx_PyInt_From_enum____arrow_3a__3a_Type_3a__3a_type(enum arrow::Type::type
value) {
const enum arrow::Type::type neg_one = (enum arrow::Type::type) -1,
const_zero = (enum arrow::Type::type) 0;
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(enum arrow::Type::type) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(enum arrow::Type::type) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
} else if (sizeof(enum arrow::Type::type) <= sizeof(unsigned
PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
}
} else {
if (sizeof(enum arrow::Type::type) <= sizeof(long)) {
return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
} else if (sizeof(enum arrow::Type::type) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(enum arrow::Type::type),
little, !is_unsigned);
}
}
{code}
> [Python] Multiple warnings with -Wconversion
> --------------------------------------------
>
> Key: ARROW-2347
> URL: https://issues.apache.org/jira/browse/ARROW-2347
> Project: Apache Arrow
> Issue Type: Bug
> Reporter: Antoine Pitrou
> Priority: Minor
>
> There are multiple warnings when compiling the Cython-generated code with
> {{-Wconversion}}:
> {code}
> /home/antoine/arrow/python/build/temp.linux-x86_64-3.6/lib.cxx: In function
> 'PyObject* __pyx_pf_7pyarrow_3lib_62union(PyObject*, PyObject*, PyObject*)':
> /home/antoine/arrow/python/build/temp.linux-x86_64-3.6/lib.cxx:23850:45:
> warning: conversion to 'std::vector<unsigned char>::value_type {aka unsigned
> char}' from 'int' may alter its value [-Wconversion]
> __pyx_v_type_codes.push_back(__pyx_v_i);
> ^
> /home/antoine/arrow/python/build/temp.linux-x86_64-3.6/lib.cxx: In function
> 'PyObject*
> __Pyx_PyInt_From_enum____arrow_3a__3a_Type_3a__3a_type(arrow::Type::type)':
> /home/antoine/arrow/python/build/temp.linux-x86_64-3.6/lib.cxx:125758:70:
> warning: the result of the conversion is unspecified because '-1' is outside
> the range of type 'arrow::Type::type' [-Wconversion]
> const enum arrow::Type::type neg_one = (enum arrow::Type::type) -1,
> const_zero = (enum arrow::Type::type) 0;
> ^
> /home/antoine/arrow/python/build/temp.linux-x86_64-3.6/lib.cxx: In function
> 'PyObject*
> __Pyx_PyInt_From_enum____arrow_3a__3a_UnionMode_3a__3a_type(arrow::UnionMode::type)':
> /home/antoine/arrow/python/build/temp.linux-x86_64-3.6/lib.cxx:125789:80:
> warning: the result of the conversion is unspecified because '-1' is outside
> the range of type 'arrow::UnionMode::type' [-Wconversion]
> const enum arrow::UnionMode::type neg_one = (enum
> arrow::UnionMode::type) -1, const_zero = (enum arrow::UnionMode::type) 0;
>
> ^
> /home/antoine/arrow/python/build/temp.linux-x86_64-3.6/lib.cxx: In function
> 'PyObject*
> __Pyx_PyInt_From_enum____arrow_3a__3a_TimeUnit_3a__3a_type(arrow::TimeUnit::type)':
> /home/antoine/arrow/python/build/temp.linux-x86_64-3.6/lib.cxx:125820:78:
> warning: the result of the conversion is unspecified because '-1' is outside
> the range of type 'arrow::TimeUnit::type' [-Wconversion]
> const enum arrow::TimeUnit::type neg_one = (enum
> arrow::TimeUnit::type) -1, const_zero = (enum arrow::TimeUnit::type) 0;
>
> ^
> {code}
> (also similar warnings for _parquet.pyx due to Parquet enumerations)
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)