pyenchant / pyenchant

spellchecking library for python
https://pyenchant.github.io/pyenchant/
GNU Lesser General Public License v2.1
597 stars 97 forks source link

pyenchant fails in Python 3.12 and 3.13 on macOS 10.15 (Catalina) #314

Open JD-Veiga opened 9 months ago

JD-Veiga commented 9 months ago

Hello,

pyenchant fails when run in Python 3.12 on a macOS 10.15 system. I have tested pyenchant 3.2.2 and 3.3.0rc1 and both versions fail under Python 3.12. They run well under Python 3.11.

Failure can be check with one-line command: python3.12 -c "import enchant; broker = enchant.Broker(); print(broker.describe()); print(broker.list_languages())" which causes a Abort trap: 6 error message when broker.describe is run.

The enchant library version is 2.3.4 (however, I do not think this is the cause of the bug).

Running tests outputs the following information:


Running with Enchant C library at version 2.3.4
================================================================================================================= test session starts ==================================================================================================================
platform darwin -- Python 3.12.0, pytest-7.4.3, pluggy-1.3.0 -- pyenchant-3.3.0rc1/.tox/py312/bin/python
cachedir: .tox/py312/.pytest_cache
rootdir: pyenchant-3.3.0rc1
plugins: cov-4.1.0
collected 64 items                                                                                                                                                                                                                                     

tests/test_broker.py::test_all_langs_are_available Fatal Python error: Aborted

Current thread 0x000000010c11bdc0 (most recent call first):
  File "pyenchant-3.3.0rc1/enchant/_enchant.py", line 257 in broker_list_dicts
  File "pyenchant-3.3.0rc1/enchant/__init__.py", line 407 in list_dicts
  File "pyenchant-3.3.0rc1/enchant/__init__.py", line 430 in list_languages
  File "pyenchant-3.3.0rc1/tests/test_broker.py", line 15 in test_all_langs_are_available
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/python.py", line 194 in pytest_pyfunc_call
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/python.py", line 1792 in runtest
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/runner.py", line 169 in pytest_runtest_call
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/runner.py", line 262 in <lambda>
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/runner.py", line 341 in from_call
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/runner.py", line 261 in call_runtest_hook
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/runner.py", line 222 in call_and_report
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/runner.py", line 133 in runtestprotocol
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/runner.py", line 114 in pytest_runtest_protocol
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/main.py", line 350 in pytest_runtestloop
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/main.py", line 325 in _main
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/main.py", line 271 in wrap_session
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/main.py", line 318 in pytest_cmdline_main
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/config/__init__.py", line 169 in main
  File "pyenchant-3.3.0rc1/.tox/py312/lib/python3.12/site-packages/_pytest/config/__init__.py", line 192 in console_main
  File "pyenchant-3.3.0rc1/.tox/py312/bin/pytest", line 8 in <module>
py312: exit -6 (3.71 seconds) pyenchant-3.3.0rc1> pytest --cov --cov-report term --cov-report html --verbose --capture=no pid=11379
.pkg: _exit> python /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg-cpython311: _exit> python /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
  py311: OK (81.35=setup[67.17]+cmd[0.58,13.60] seconds)
  py312: FAIL code -6 (74.05=setup[68.88]+cmd[1.46,3.71] seconds)
  evaluation failed :( (155.58 seconds)

Thank you.

JD-Veiga commented 9 months ago

I have (painfully) upgraded enchant C library to 2.6.2 (latest) and got the same bug.

enchant library compiles but fails tests in macOS 10.15. However, it runs smoothly when invoked from terminal (is this alarming?). [The same happens with enchant 2.3.4]

On the contrary, pyenchant running on Python 3.12 and calling enchant 2.6.2 does not work (as it does not when calling enchant 2.3.4). Intriguingly, pyenchant works when it is used from Python 3.11. That is just the same behaviour with previous version enchant 2.3.4.

I must say that enchant 2.3.4 also fails tests when compiled in macOS 10.15. Does it means that the bug is not buried in enchant library but in Python itself --something Python ABI-related, maybe?

reagle commented 6 months ago

I can't use pyenchant under 3.12 on macOS 14.3.1 23D60 arm64.

Python 3.12.2 (main, Feb 27 2024, 08:43:18) [Clang 15.0.0 (clang-1500.1.0.2.5)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.22.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from enchant import Dict
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 1
----> 1 from enchant import Dict

ImportError: cannot import name 'Dict' from 'enchant' (/Users/reagle/.pyenv/versions/3.12.2/lib/python3.12/site-packages/enchant/__init__.py)
JD-Veiga commented 6 months ago

Hi, @reagle:

I think that your problem is different from mine.

Are you sure that enchant is properly installed? Dict class is defined in enchant/__init__.py and should be imported without any major problem (I can import it without any issue).

You can check /Users/reagle/.pyenv/versions/3.12.2/lib/python3.12/site-packages/enchant/__init__.py and search for "class Dict". It must be there (it have been there for ages, according to github).

Which version of pyenchant are you running?

reagle commented 6 months ago

@JD-Veiga, I'm on macOS 14.4 23E214 arm64 and my __init__.py is empty.

total 40K
-rw-r--r-- 1 reagle staff    0 Feb 27 08:44 __init__.py
-rw-r--r-- 1 reagle staff  12K Feb 27 08:44 _enchant.py
drwxr-xr-x 6 reagle staff  192 Feb 27 08:44 checker/
-rw-r--r-- 1 reagle staff 2.1K Feb 27 08:44 errors.py
-rw-r--r-- 1 reagle staff  245 Feb 27 08:44 messenger.py
-rw-r--r-- 1 reagle staff 9.0K Feb 27 08:44 pypwl.py
drwxr-xr-x 4 reagle staff  128 Feb 27 08:44 tokenize/
-rw-r--r-- 1 reagle staff 4.2K Feb 27 08:44 utils.py
==> enchant: stable 2.6.7 (bottled)
Spellchecker wrapping library
https://abiword.github.io/enchant/
/opt/homebrew/Cellar/enchant/2.6.7 (29 files, 488.5KB) *
  Poured from bottle using the formulae.brew.sh API on 2024-02-09 at 08:28:21
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/e/enchant.rb
License: LGPL-2.1-or-later
==> Dependencies
Build: pkg-config
Required: aspell, glib
==> Analytics
install: 2,997 (30 days), 10,691 (90 days), 32,353 (365 days)
install-on-request: 1,689 (30 days), 5,715 (90 days), 17,135 (365 days)
build-error: 0 (30 days)
Name: pyenchant
Version: 3.2.2
Summary: Python bindings for the Enchant spellchecking system
Home-page: https://pyenchant.github.io/pyenchant/
Author: Dimitri Merejkowsky
Author-email: d.merej@gmail.com
License: LGPL
Location: /Users/reagle/.pyenv/versions/3.12.2/lib/python3.12/site-packages
Requires: 
Required-by: 
JD-Veiga commented 6 months ago

I think that it must not be empty whichever the system or version of pyenchant. Probably the installation has failed at some point.

From your output, I guess that you are using pyenv. I cannot provide any useful help on pyenv since I rather use it.

I can only suggest to re-install pyenchant. In my case, since I use pip, running pip uninstall pyenchant; pip install pyenchant should do the job.

I do not really know if there are specific commands in pyenv for doing this particular task, sorry. I suppose that you can simply run pip commands in the virtual environment, but I am not sure at all.

JD-Veiga commented 6 months ago

I have tried pyenchat in Python 3.13.0a5 and it still causes a Abort trap: 6 error .

macOS 10.15.7 (19H2026) Python 3.13.0a5 pyenchant 3.2.2 enchant 1.6.0 enchant2 2.6.7

JD-Veiga commented 5 months ago

Still happens en Python 3.12.3

JD-Veiga commented 5 months ago

Python 3.13.0a6 still has this bug.