Skip to content

Commit 6b71715

Browse files
author
Steve Canny
committed
tbl: base _Columns on Parented
1 parent bf42778 commit 6b71715

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

docx/table.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def columns(self):
5151
"""
5252
|_Columns| instance containing the sequence of rows in this table.
5353
"""
54-
return _Columns(self._tbl)
54+
return _Columns(self._tbl, self)
5555

5656
@lazyproperty
5757
def rows(self):
@@ -179,13 +179,13 @@ def _tr_lst(self):
179179
return self._tbl.tr_lst
180180

181181

182-
class _Columns(object):
182+
class _Columns(Parented):
183183
"""
184184
Sequence of |_Column| instances corresponding to the columns in a table.
185185
Supports ``len()``, iteration and indexed access.
186186
"""
187-
def __init__(self, tbl):
188-
super(_Columns, self).__init__()
187+
def __init__(self, tbl, parent):
188+
super(_Columns, self).__init__(parent)
189189
self._tbl = tbl
190190

191191
def __getitem__(self, idx):

tests/test_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def it_raises_on_indexed_access_out_of_range(self, columns_fixture):
271271
def columns_fixture(self):
272272
column_count = 2
273273
tbl = _tbl_bldr(rows=2, cols=column_count).element
274-
columns = _Columns(tbl)
274+
columns = _Columns(tbl, None)
275275
return columns, column_count
276276

277277

0 commit comments

Comments
 (0)