Skip to content

Commit e8380c5

Browse files
committed
Tables that look similar to DAOPhot could cause guesing to fail -> fixed.
closes astropy#3319
1 parent 9828969 commit e8380c5

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎CHANGES.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,9 @@ Bug Fixes
474474

475475
- The IPAC table reader now correctly interprets abbreviated column types. [#3279]
476476

477+
- Tables that look almost, but not quite like DAOPhot tables could cause guessing
478+
to fail. [#3342]
479+
477480
- ``astropy.io.fits``
478481

479482
- Setting ``memmap=True`` in ``fits.open`` and related functions now raises a ValueError if opening a file in memory-mapped mode is impossible. [#2298]

‎astropy/io/ascii/tests/test_read.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,3 +913,20 @@ def test_ipac_abbrev():
913913
assert dat[name].dtype.kind == 'i'
914914
for name in dat.columns[10:12]:
915915
assert dat[name].dtype.kind in ('U', 'S')
916+
917+
918+
def test_almost_but_not_quite_daophot():
919+
'''Regression test for #3319.
920+
This tables looks so close to a daophot table, that the daophot reader gets
921+
quite far before it fails with an AttributeError.
922+
923+
Note that this table will actually be read as Commented Header table with
924+
the columns ['some', 'header', 'info'].
925+
'''
926+
lines = ["# some header info",
927+
"#F header info beginning with 'F'",
928+
"1 2 3",
929+
"4 5 6",
930+
"7 8 9"]
931+
dat = ascii.read(lines)
932+
assert len(dat) == 3

‎astropy/io/ascii/ui.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def _guess(table, read_kwargs, format, fast_reader):
220220
reader.guessing = True
221221
return reader.read(table)
222222

223-
except (core.InconsistentTableError, ValueError, TypeError,
223+
except (core.InconsistentTableError, ValueError, TypeError, AttributeError,
224224
core.OptionalTableImportError, core.ParameterError, cparser.CParserError):
225225
failed_kwargs.append(guess_kwargs)
226226
else:

0 commit comments

Comments
 (0)