diff --git a/python/tests/test_tables.py b/python/tests/test_tables.py index 1f573b5b94..154b6c0ce4 100644 --- a/python/tests/test_tables.py +++ b/python/tests/test_tables.py @@ -825,7 +825,7 @@ def test_bad_offsets(self): def test_replace_with_wrong_class(self): t = self.table_class() - with pytest.raises(TypeError, match="wrong type"): + with pytest.raises(TypeError, match="is required"): t.replace_with(tskit.BaseTable(None, None)) diff --git a/python/tskit/tables.py b/python/tskit/tables.py index aa25f762a8..33090b0905 100644 --- a/python/tskit/tables.py +++ b/python/tskit/tables.py @@ -591,20 +591,7 @@ def append(self, row): def replace_with(self, other): # Overwrite the contents of this table with a copy of the other table - params = {} - for column in self.column_names: - try: - params[column] = getattr(other, column) - except AttributeError: - raise TypeError( - "Replacement table has wrong type: it lacks a {column} column" - ) - try: - # Not all tables have a metadata_schema: if they do, encode it with repr - params["metadata_schema"] = repr(other.metadata_schema) - except AttributeError: - pass - self.set_columns(**params) + self.set_columns(**other.asdict()) def clear(self): """