Skip to content

spaCy 3.8.16 tokenizer OverflowError on Windows after upgrading preshed 3.0.13 → 3.0.14 #14058

Open

Description

@zacthinks

Title: spaCy 3.8.16 tokenizer OverflowError on Windows after upgrading preshed 3.0.13 → 3.0.14

Description

Loading en_core_web_sm 3.8.0 fails with an OverflowError during tokenizer deserialization when using preshed==3.0.14. Reverting to preshed==3.0.13 resolves the failure.

Minimal reproduction

Reproduced in a clean Windows Python 3.12 virtual environment using pip, independently of any application or project-specific dependencies.

py -3.12 -m venv .venv

.\.venv\Scripts\python.exe -m pip install "spacy==3.8.16" "preshed==3.0.13" "en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl"

.\.venv\Scripts\python.exe -c "import spacy; print(spacy.load('en_core_web_sm').pipe_names)"

Result: Success.

Then upgrade only Preshed:

.\.venv\Scripts\python.exe -m pip install --no-deps "preshed==3.0.14"

.\.venv\Scripts\python.exe -c "import spacy; print(spacy.load('en_core_web_sm').pipe_names)"

Result: Failure.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\<user>\local_projects\preshed-repro\.venv\Lib\site-packages\spacy\__init__.py", line 74, in load
    return util.load_model(
           ^^^^^^^^^^^^^^^^
  File "C:\Users\<user>\local_projects\preshed-repro\.venv\Lib\site-packages\spacy\util.py", line 524, in load_model
    return load_model_from_package(name, **kwargs)  # type: ignore[arg-type]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user>\local_projects\preshed-repro\.venv\Lib\site-packages\spacy\util.py", line 560, in load_model_from_package
    return cls.load(
           ^^^^^^^^^
  File "C:\Users\<user>\local_projects\preshed-repro\.venv\Lib\site-packages\en_core_web_sm\__init__.py", line 10, in load
    return load_model_from_init_py(__file__, **overrides)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user>\local_projects\preshed-repro\.venv\Lib\site-packages\spacy\util.py", line 743, in load_model_from_init_py
    return load_model_from_path(
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user>\local_projects\preshed-repro\.venv\Lib\site-packages\spacy\util.py", line 608, in load_model_from_path
    return nlp.from_disk(model_path, exclude=exclude, overrides=overrides)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user>\local_projects\preshed-repro\.venv\Lib\site-packages\spacy\language.py", line 2249, in from_disk
    util.from_disk(path, deserializers, exclude)  # type: ignore[arg-type]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user>\local_projects\preshed-repro\.venv\Lib\site-packages\spacy\util.py", line 1450, in from_disk
    reader(path / key)
  File "C:\Users\<user>\local_projects\preshed-repro\.venv\Lib\site-packages\spacy\language.py", line 2235, in <lambda>
    deserializers["tokenizer"] = lambda p: self.tokenizer.from_disk(  # type: ignore[union-attr]
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "spacy/tokenizer.pyx", line 787, in spacy.tokenizer.Tokenizer.from_disk
    self.from_bytes(bytes_data, exclude=exclude)
  File "spacy/tokenizer.pyx", line 833, in spacy.tokenizer.Tokenizer.from_bytes
    self.rules = {}
  File "spacy/tokenizer.pyx", line 128, in spacy.tokenizer.Tokenizer.rules.__set__
    self._flush_specials()
  File "spacy/tokenizer.pyx", line 239, in spacy.tokenizer.Tokenizer._flush_specials
    del self._specials[k]
OverflowError: Python int too large to convert to C ssize_t

The same failure was initially observed in a Python 3.11 environment and subsequently reproduced independently with Python 3.12.

Info about spaCy

  • spaCy version: 3.8.16
  • Platform: Windows-11-10.0.26200-SP0
  • Python version: 3.12.6
  • Pipelines: en_core_web_sm (3.8.0)

Activity

  1. boxydog commented on Oct 25, 2026

    @boxydog

    Same failure here, and it isn't Windows-specific. spaCy 3.8.16, en_core_web_sm 3.8.0:

    • Linux (GitHub Actions ubuntu runner, Python 3.13.16): fails with preshed 3.0.14
    • macOS 12.7.6 x86_64, Python 3.13.0: fails with preshed 3.0.14

    Same traceback, ending in Tokenizer._flush_specials -> del self._specials[k] -> OverflowError: Python int too large to convert to C ssize_t.

    On macOS, going back to preshed 3.0.13 fixes it, with cymem 2.0.16, murmurhash 1.0.16, numpy 2.5.4 and srsly 2.5.5 left at their new versions. Pinning preshed<3.0.14 works as a stopgap.

  2. SergeyShk commented on Oct 25, 2026

    @SergeyShk
    Contributor

    Same here with spaCy 3.8.15 as well as 3.8.16 (macOS arm64, CPython 3.11-3.14). A repro without a pipeline package:

    uv run --isolated --no-project --with spacy==3.8.16 --with preshed==3.0.14 python -c "import spacy; nlp = spacy.blank('en'); nlp.tokenizer.rules = nlp.tokenizer.rules"
    
    OverflowError: Python int too large to convert to C ssize_t
    

    It passes with preshed==3.0.13, and fails the same way with spacy==3.8.15. Except on Python 3.13, it reproduces without spaCy. With 3.0.14, setting, getting and deleting any key from 2**63 raise the same error, while 3.0.13 accepts them:

    uv run --isolated --no-project --python 3.11 --with preshed==3.0.14 python -c "from preshed.maps import PreshMap; m = PreshMap(); m[2**63] = 1"
    

    These direct calls fail on Python 3.11, 3.12 and 3.14. On 3.13 they pass, and only the tokenizer fails.

    The cause looks like the Cython used to build the wheels, not a change in preshed:

    • The sdists of 3.0.13 and 3.0.14 differ only in the version, python_requires (<3.16) and the Python 3.15 classifier.
    • The wheels were built with different Cython versions. In the cp313 macOS arm64 wheels, maps.*.so of 3.0.13 contains _cython_3_2_4, and that of 3.0.14 contains _cython_3_3_0. The build requirement is cython>=3.1, unpinned.
    • Building 3.0.14 from source with cython==3.2.4 as a build constraint makes the repro pass. Building it with cython==3.3.0 makes it fail, and so does building 3.0.13 with it:
    uv venv --python 3.13 venv && VIRTUAL_ENV=venv uv pip install --no-cache --no-binary preshed --build-constraints <(echo "cython==3.3.0") spacy==3.8.16 preshed==3.0.13
    

    So any build of preshed from source now gets Cython 3.3.0 and breaks, on a platform without wheels or with --no-binary. Pinning Cython below 3.3 in the build requirements and re-releasing (e.g. as 3.0.15) would likely fix it. Meanwhile preshed!=3.0.14 (with the wheels) works as a stopgap

  3. added a commit that references this issue on Oct 25, 2026
  4. acoustesh commented on Oct 25, 2026

    @acoustesh

    Confirmed that preshed==3.0.15 fixes this. On Linux, Python 3.14.8, spaCy 3.8.16 with es_core_news_sm 3.8.0, spacy.load() raised the same OverflowError in Tokenizer._flush_specials with preshed 3.0.14. It loads fine with 3.0.13 and with 3.0.15, so the preshed<3.0.14 pin should no longer be needed once 3.0.15 is resolved.

  5. ldej commented on Oct 29, 2026

    @ldej

    Same failure on a different interpreter and platform, which supports preshed being the cause rather than spaCy or the OS.

    Linux x86_64, CPython 3.15.2, spaCy 3.8.18 from the published cp315 wheel, en_core_web_sm 3.8.0:

    preshed install spacy.load("en_core_web_sm")
    3.0.13 no cp315 wheel, compiled from sdist OverflowError: Python int too large to convert to C ssize_t in Tokenizer._flush_specials
    3.0.15 cp315 wheel loads, pipeline intact

    Only preshed changed between the two runs, so the tokenizer crash tracks preshed rather than the interpreter, and 3.0.15 resolves it here too.

    One downstream consequence if it helps triage: presidio-analyzer 2.2.366 pins preshed<3.0.14, so anyone using it on 3.15 gets the broken build unless they override the pin. I opened data-privacy-stack/presidio#2431 about relaxing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions