diff --git a/idna/core.py b/idna/core.py
index b861d14..2c193d6 100644
--- a/idna/core.py
+++ b/idna/core.py
@@ -296,6 +296,8 @@ def ulabel(label):
     label = label.lower()
     if label.startswith(_alabel_prefix):
         label = label[len(_alabel_prefix):]
+        if not label:
+            raise IDNAError('Malformed A-label, no Punycode eligible content found')
         if label.decode('ascii')[-1] == '-':
             raise IDNAError('A-label must not end with a hyphen')
     else:

IndexError with new trailing hyphen check
#64 introduced the following uncaught exception. Is this intended?

```python
>>> idna.ulabel('xn--')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/John/.pyenv/versions/3.6.5/Python.framework/Versions/3.6/lib/python3.6/site-packages/idna/core.py", line 303, in ulabel
    if label.decode('ascii')[-1] == '-':
IndexError: string index out of range
```

I would've expected `UnicodeError` or `IDNAError`, which are more descriptive.
diff --git a/tests/test_idna.py b/tests/test_idna.py
index b62b9c6..9e1d2d9 100755
--- a/tests/test_idna.py
+++ b/tests/test_idna.py
@@ -258,6 +258,7 @@ class IDNATests(unittest.TestCase):
                          '\u0521\u0525\u0523-\u0523\u0523-----\u0521\u0523\u0523\u0523.aa')
         self.assertRaises(idna.IDNAError, idna.decode, 'XN---------90GGLBAGAAC.AA')
         self.assertRaises(idna.IDNAError, idna.decode, 'xn---------90gglbagaac.aa')
+        self.assertRaises(idna.IDNAError, idna.decode, 'xn--')
 
 if __name__ == '__main__':
     unittest.main()

pip install -e .
parse_log_pytest
pytest
pytest
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
-e git+https://github.com/kjd/idna.git@3062063d477591228a4b4d000688ef4e7ab7cf81#egg=idna
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
pytest @ file:///croot/pytest_1738938843180/work
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work

name: idna
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - exceptiongroup=1.2.0=py39h06a4308_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - packaging=24.2=py39h06a4308_0
  - pip=25.0=py39h06a4308_0
  - pluggy=1.5.0=py39h06a4308_0
  - pytest=8.3.4=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py39h06a4308_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
prefix: /opt/conda/envs/idna

tests/test_idna.py::IDNATests::test_decode
tests/test_idna.py::IDNATests::testIDNTLDALabels tests/test_idna.py::IDNATests::testIDNTLDULabels tests/test_idna.py::IDNATests::test_check_bidi tests/test_idna.py::IDNATests::test_check_hyphen_ok tests/test_idna.py::IDNATests::test_check_initial_combiner tests/test_idna.py::IDNATests::test_encode tests/test_idna.py::IDNATests::test_valid_contextj tests/test_idna.py::IDNATests::test_valid_contexto tests/test_idna.py::IDNATests::test_valid_label_length
idna/core.py
idna/core.py