def _upgrade_datamatrix_index(dm):
    """Fixes the Index object of deprecated versions of DataMatrix."""
    from datamatrix._datamatrix._index import Index
    object.__setattr__(dm, '_rowid', Index(dm._rowid._l))
    for colname, col in dm.columns:
        if hasattr(col._rowid, '_l'):
            object.__setattr__(col, '_rowid', Index(col._rowid._l))
        else:
            object.__setattr__(col, '_rowid', Index(col._rowid))
    return dm
