Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7050F200CC1 for ; Mon, 10 Jul 2017 17:00:48 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 6EB2A160C7C; Mon, 10 Jul 2017 15:00:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B46E3160C70 for ; Mon, 10 Jul 2017 17:00:47 +0200 (CEST) Received: (qmail 42794 invoked by uid 500); 10 Jul 2017 15:00:46 -0000 Mailing-List: contact commits-help@arrow.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@arrow.apache.org Delivered-To: mailing list commits@arrow.apache.org Received: (qmail 42785 invoked by uid 99); 10 Jul 2017 15:00:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Jul 2017 15:00:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B8415DFF8A; Mon, 10 Jul 2017 15:00:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: uwe@apache.org To: commits@arrow.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: arrow git commit: ARROW-1201: [Python] Incomplete Python types cause a core dump when repr-ing Date: Mon, 10 Jul 2017 15:00:46 +0000 (UTC) archived-at: Mon, 10 Jul 2017 15:00:48 -0000 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 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 Authored: Mon Jul 10 17:00:42 2017 +0200 Committer: Uwe L. Korn 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)