Repository: astropy/astropy

Issue:
BUG: wrongly assumed Path when parsing html
I see this in one of the astroquery tests (reproduce it with `pytest -P mpc -R`, I may write up an MRE without referring to astroquery later):
 It's clearly caused by 3bf33f68ad220a00384d42478e43955f62454afe, the tests pass with 6.1.7
```

self = <astroquery.mpc.tests.test_mpc_remote.TestMPC object at 0x136b73740>

    def test_get_observations(self):
        # asteroids
        a = mpc.MPC.get_observations(2)
        assert a['number'][0] == 2
    
        a = mpc.MPC.get_observations(12893)
        assert a['number'][0] == 12893
        assert a['desig'][-1] == '1998 QS55'
>       a = mpc.MPC.get_observations("2019 AA")

astroquery/mpc/tests/test_mpc_remote.py:97: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
astroquery/utils/class_or_instance.py:25: in f
    return self.fn(obj, *args, **kwds)
astroquery/utils/process_asyncs.py:29: in newmethod
    result = self._parse_result(response, verbose=verbose)
astroquery/mpc/core.py:1212: in _parse_result
    data = ascii.read("\n".join([o['original_record']
../../../.pyenv/versions/3.12.1/lib/python3.12/site-packages/astropy/io/ascii/ui.py:398: in read
    new_kwargs["guess_html"] = _probably_html(table)
../../../.pyenv/versions/3.12.1/lib/python3.12/site-packages/astropy/io/ascii/ui.py:148: in _probably_html
    table_path = Path(table).expanduser()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = PosixPath('~0FR1K19A00A  C2011 01 29.24643 01 18 02.537-02 41 30.21         22.2 wL~3JL8F51\n~0FR1K19A00A  C2011 01 29...47 46 56.60         20.93GV~7ukZG96\n~0FR1K19A00A 1C2024 03 03.20377105 56 18.827+47 46 54.95         20.97GV~7ukZG96')

    def expanduser(self):
        """ Return a new path with expanded ~ and ~user constructs
        (as returned by os.path.expanduser)
        """
        if (not (self.drive or self.root) and
            self._tail and self._tail[0][:1] == '~'):
            homedir = self._flavour.expanduser(self._tail[0])
            if homedir[:1] == "~":
>               raise RuntimeError("Could not determine home directory.")
E               RuntimeError: Could not determine home directory.

../../../.pyenv/versions/3.12.1/lib/python3.12/pathlib.py:1406: RuntimeError
==================================================================== short test summary info ====================================================================
FAILED astroquery/mpc/tests/test_mpc_remote.py::TestMPC::test_get_observations - RuntimeError: Could not determine home directory.

```


Discussion:
github-actions[bot]: Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  - [ ] Do the proposed changes actually accomplish desired goals?
  - [ ] Do the proposed changes follow the [Astropy coding guidelines](https://docs.astropy.org/en/latest/development/codeguide.html)?
  - [ ] Are tests added/updated as required? If so, do they follow the [Astropy testing guidelines](https://docs.astropy.org/en/latest/development/testguide.html)?
  - [ ] Are docs added/updated as required? If so, do they follow the [Astropy documentation guidelines](https://docs.astropy.org/en/latest/development/docguide.html)?
  - [ ] Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for [rebase](https://docs.astropy.org/en/latest/development/development_details.html#rebase-if-necessary) and [squash](https://docs.astropy.org/en/latest/development/development_details.html#squash-if-necessary).
  - [ ] Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the [bot](https://docs.astropy.org/en/latest/development/development_details.html#pre-commit).
  - [ ] Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  - [ ] Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  - [ ] At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) *before* merge.
github-actions[bot]: 👋 Thank you for your draft pull request! Do you know that you can use `[ci skip]` or `[skip ci]` in your commit messages to skip running continuous integration tests until you are ready?
neutrinoceros: Whoops, just saw that @pllim beat me to it #17564. Well, that makes for any easy review for me 😅 

Patch:
diff --git a/astropy/io/ascii/ui.py b/astropy/io/ascii/ui.py
index 1a7334f3bb..b608bb2d6f 100644
--- a/astropy/io/ascii/ui.py
+++ b/astropy/io/ascii/ui.py
@@ -145,8 +145,10 @@ def _probably_html(table, maxchars=100000):
             return True
 
         # Filename ending in .htm or .html which exists
-        table_path = Path(table).expanduser()
-        if re.search(r"\.htm[l]?$", table[-5:], re.IGNORECASE) and table_path.is_file():
+        if (
+            re.search(r"\.htm[l]?$", table[-5:], re.IGNORECASE)
+            and Path(table).expanduser().is_file()
+        ):
             return True
 
         # Table starts with HTML document type declaration
diff --git a/astropy/units/cds.py b/astropy/units/cds.py
index f4ac6436f7..c6022456d6 100644
--- a/astropy/units/cds.py
+++ b/astropy/units/cds.py
@@ -119,7 +119,7 @@ def _initialize_module():
         (["mmHg"], 133.322387415 * u.Pa, "millimeter of mercury"),
         (["mol"], u.mol, "mole"),
         (["mp"], _si.m_p, "proton mass"),
-        (["solMass", "Msun"], u.solMass, "solar mass"),
+        (["Msun", "solMass"], u.solMass, "solar mass"),
         ((["mu0", "µ0"], []), _si.mu0, "magnetic constant"),
         (["muB"], _si.muB, "Bohr magneton"),
         (["N"], u.N, "Newton"),
diff --git a/docs/changes/io.ascii/17565.bugfix.rst b/docs/changes/io.ascii/17565.bugfix.rst
new file mode 100644
index 0000000000..c0f460c17a
--- /dev/null
+++ b/docs/changes/io.ascii/17565.bugfix.rst
@@ -0,0 +1,1 @@
+Fixed parsing ASCII table with data that starts with a tilda.
diff --git a/docs/changes/units/17560.bugfix.rst b/docs/changes/units/17560.bugfix.rst
deleted file mode 100644
index 26dbb08971..0000000000
--- a/docs/changes/units/17560.bugfix.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-Previously the string representation of the ``solMass`` unit in the ``"cds"``
-format depended on whether the unit was imported directly from ``units`` or
-from ``units.cds``.
-Although both representations were valid according to the CDS standard, the
-inconsistency was nonetheless needlessly surprising.
-The representation of ``units.cds.solMass`` has been changed to match the
-representation of ``units.solMass``.


Test patch:
diff --git a/astropy/io/ascii/tests/test_read.py b/astropy/io/ascii/tests/test_read.py
index ab31fc7e93..f9c3f36b89 100644
--- a/astropy/io/ascii/tests/test_read.py
+++ b/astropy/io/ascii/tests/test_read.py
@@ -1497,6 +1497,13 @@ def test_probably_html(home_is_data):
         ],
         (" <! doctype htm > ", " hello world"),
         [[1, 2, 3]],
+        # regression tests for https://github.com/astropy/astropy/issues/17562
+        "~itsatrap",  # looks like a Path, but isn't
+        (
+            "~0FR1K19A00A  C2011 01 29.24643 01 18 02.537-02 41 30.21         22.2 wL~3JL8F51\n"
+            "~0FR1K19A00A  C2011 01 29...47 46 56.60         20.93GV~7ukZG96\n"
+            "~0FR1K19A00A 1C2024 03 03.20377105 56 18.827+47 46 54.95         20.97GV~7ukZG96"
+        ),
     ):
         assert _probably_html(tabl0) is False
 
diff --git a/astropy/table/tests/test_showtable.py b/astropy/table/tests/test_showtable.py
index e9595bb566..82125f91b7 100644
--- a/astropy/table/tests/test_showtable.py
+++ b/astropy/table/tests/test_showtable.py
@@ -195,10 +195,10 @@ def test_hide_unit(capsys):
     showtable.main([os.path.join(ASCII_ROOT, "data/cds.dat"), "--format", "ascii.cds"])
     out, err = capsys.readouterr()
     assert out.splitlines() == [
-        "Index RAh RAm  RAs  DE- DEd  DEm    DEs   Match Class  AK   Fit   ",
-        "       h  min   s       deg arcmin arcsec             mag GsolMass",
-        "----- --- --- ----- --- --- ------ ------ ----- ----- --- --------",
-        "    1   3  28 39.09   +  31      6    1.9    --    I*  --     1.35",
+        "Index RAh RAm  RAs  DE- DEd  DEm    DEs   Match Class  AK  Fit ",
+        "       h  min   s       deg arcmin arcsec             mag GMsun",
+        "----- --- --- ----- --- --- ------ ------ ----- ----- --- -----",
+        "    1   3  28 39.09   +  31      6    1.9    --    I*  --  1.35",
     ]
 
     showtable.main(
diff --git a/astropy/units/tests/test_format.py b/astropy/units/tests/test_format.py
index c933b41d99..3c8596644e 100644
--- a/astropy/units/tests/test_format.py
+++ b/astropy/units/tests/test_format.py
@@ -192,13 +192,6 @@ def test_cds_angstrom_str():
     assert u.cds.Angstrom.name == "Angstrom"
 
 
-def test_cds_solMass_str():
-    # CDS allows writing solar mass as Msun or solMass,
-    # but cds.solMass and u.solMass should be consistent.
-    assert u.solMass.to_string("cds") == "solMass"
-    assert u.cds.solMass.to_string("cds") == "solMass"
-
-
 # These examples are taken from the EXAMPLES section of
 # https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/general/ogip_93_001/
 @pytest.mark.parametrize(