arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-970: [Python] Nicer experience if user accidentally calls pyarrow.Table ctor directly
Date Wed, 17 May 2017 19:37:19 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 0eec40aa5 -> 37cdc6e99


ARROW-970: [Python] Nicer experience if user accidentally calls pyarrow.Table ctor directly

This segfaulted before

Author: Wes McKinney <wes.mckinney@twosigma.com>

Closes #702 from wesm/ARROW-970 and squashes the following commits:

508d9899 [Wes McKinney] Add some null checks into Table methods


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/37cdc6e9
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/37cdc6e9
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/37cdc6e9

Branch: refs/heads/master
Commit: 37cdc6e99bd935c3ce23e840d6d5ba4e070bc3b6
Parents: 0eec40a
Author: Wes McKinney <wes.mckinney@twosigma.com>
Authored: Wed May 17 15:37:15 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Wed May 17 15:37:15 2017 -0400

----------------------------------------------------------------------
 python/pyarrow/table.pxi           | 8 ++++++--
 python/pyarrow/tests/test_table.py | 5 +++++
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/37cdc6e9/python/pyarrow/table.pxi
----------------------------------------------------------------------
diff --git a/python/pyarrow/table.pxi b/python/pyarrow/table.pxi
index c9915c1..25a4f84 100644
--- a/python/pyarrow/table.pxi
+++ b/python/pyarrow/table.pxi
@@ -825,6 +825,7 @@ cdef class Table:
         -------
         pandas.DataFrame
         """
+        self._check_nullptr()
         if nthreads is None:
             nthreads = cpu_count()
 
@@ -845,6 +846,7 @@ cdef class Table:
             list entries = []
             Column column
 
+        self._check_nullptr()
         for i in range(num_columns):
             column = self.column(i)
             entries.append((column.name, column.to_pylist()))
@@ -860,6 +862,7 @@ cdef class Table:
         -------
         pyarrow.Schema
         """
+        self._check_nullptr()
         return pyarrow_wrap_schema(self.table.schema())
 
     def column(self, int64_t i):
@@ -874,13 +877,12 @@ cdef class Table:
         -------
         pyarrow.Column
         """
-        self._check_nullptr()
-
         cdef:
             Column column = Column()
             int64_t num_columns = self.num_columns
             int64_t index
 
+        self._check_nullptr()
         if not -num_columns <= i < num_columns:
             raise IndexError(
                 'Table column index {:d} is out of range'.format(i)
@@ -947,6 +949,7 @@ cdef class Table:
         Add column to Table at position. Returns new table
         """
         cdef shared_ptr[CTable] c_table
+        self._check_nullptr()
 
         with nogil:
             check_status(self.table.AddColumn(i, column.sp_column, &c_table))
@@ -964,6 +967,7 @@ cdef class Table:
         Create new Table with the indicated column removed
         """
         cdef shared_ptr[CTable] c_table
+        self._check_nullptr()
 
         with nogil:
             check_status(self.table.RemoveColumn(i, &c_table))

http://git-wip-us.apache.org/repos/asf/arrow/blob/37cdc6e9/python/pyarrow/tests/test_table.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/tests/test_table.py b/python/pyarrow/tests/test_table.py
index ed22011..afc9520 100644
--- a/python/pyarrow/tests/test_table.py
+++ b/python/pyarrow/tests/test_table.py
@@ -275,3 +275,8 @@ def test_table_negative_indexing():
 
     with pytest.raises(IndexError):
         table[4]
+
+
+def test_table_ctor_errors():
+    with pytest.raises(ReferenceError):
+        repr(pa.Table())


Mime
View raw message