Repository: arrow Updated Branches: refs/heads/master 7870804e0 -> f73c1c3bb
ARROW-1201: [Python] Incomplete Python types cause a core dump when repr-ing Author: Phillip Cloud <cpcl...@gmail.com> Closes #826 from cpcloud/ARROW-1201 and squashes the following commits: fbf93c3 [Phillip Cloud] ARROW-1201: [Python] Incomplete Python types cause a core dump when repr-ing Project: http://git-wip-us.apache.org/repos/asf/arrow/repo Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/f73c1c3b Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/f73c1c3b Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/f73c1c3b Branch: refs/heads/master Commit: f73c1c3bb69c2edf67561569ce5f0a8ae79462db Parents: 7870804 Author: Phillip Cloud <cpcl...@gmail.com> Authored: Mon Jul 10 17:00:42 2017 +0200 Committer: Uwe L. Korn <uw...@xhochy.com> Committed: Mon Jul 10 17:00:42 2017 +0200 ---------------------------------------------------------------------- python/pyarrow/__init__.py | 9 +-------- python/pyarrow/array.pxi | 8 ++++++++ python/pyarrow/tests/test_array.py | 6 ++++++ 3 files changed, 15 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/arrow/blob/f73c1c3b/python/pyarrow/__init__.py ---------------------------------------------------------------------- diff --git a/python/pyarrow/__init__.py b/python/pyarrow/__init__.py index 771a516..4310954 100644 --- a/python/pyarrow/__init__.py +++ b/python/pyarrow/__init__.py @@ -33,13 +33,6 @@ from pyarrow.lib import (null, bool_, float16, float32, float64, binary, string, decimal, list_, struct, dictionary, field, - DataType, - DecimalType, - DictionaryType, - FixedSizeBinaryType, - TimestampType, - Time32Type, - Time64Type, Field, Schema, schema, @@ -60,7 +53,7 @@ from pyarrow.lib import (null, bool_, Date32Array, Date64Array, TimestampArray, Time32Array, Time64Array, DecimalArray, StructArray, - ArrayValue, Scalar, NA, NAType, + ArrayValue, Scalar, NA, BooleanValue, Int8Value, Int16Value, Int32Value, Int64Value, UInt8Value, UInt16Value, UInt32Value, UInt64Value, http://git-wip-us.apache.org/repos/asf/arrow/blob/f73c1c3b/python/pyarrow/array.pxi ---------------------------------------------------------------------- diff --git a/python/pyarrow/array.pxi b/python/pyarrow/array.pxi index 6a49256..9e6ac8d 100644 --- a/python/pyarrow/array.pxi +++ b/python/pyarrow/array.pxi @@ -52,6 +52,14 @@ cdef class DataType: self.type = type.get() def __str__(self): + if self.type is NULL: + raise TypeError( + '{} is incomplete. The correct way to construct types is ' + 'through public API functions named ' + 'pyarrow.int64, pyarrow.list_, etc.'.format( + type(self).__name__ + ) + ) return frombytes(self.type.ToString()) def __repr__(self): http://git-wip-us.apache.org/repos/asf/arrow/blob/f73c1c3b/python/pyarrow/tests/test_array.py ---------------------------------------------------------------------- diff --git a/python/pyarrow/tests/test_array.py b/python/pyarrow/tests/test_array.py index 7c91785..af21741 100644 --- a/python/pyarrow/tests/test_array.py +++ b/python/pyarrow/tests/test_array.py @@ -189,3 +189,9 @@ def test_dictionary_with_pandas(): categories=dictionary) tm.assert_series_equal(pd.Series(pandas2), pd.Series(ex_pandas2)) + + +def test_simple_type_construction(): + result = pa.lib.TimestampType() + with pytest.raises(TypeError): + str(result)