Skip to content

fix(cinbase): give each input method its own config instance - #1014

Open
asdf80730 wants to merge 1 commit into
EasyIME:masterfrom
asdf80730:pr/cinbase-per-ime-config
Open

asdf80730 wants to merge 1 commit into
EasyIME:masterfrom
asdf80730:pr/cinbase-per-ime-config

Conversation

@asdf80730

Copy link
Copy Markdown
Contributor

Resetting the shared module-level config in every backend constructor clobbers state that is visible to users. python/cinbase/config.py rebinds the name CinBaseConfig to a single shared instance, and each cinbase input method built its settings by calling CinBaseConfig.__init__() and then copy.deepcopy()-ing that object — so constructing a service snapped the very singleton configtool reads back to the constructor defaults, and two input methods starting at the same time could race between the reset and the copy, picking up each other's values.

  • Export the class from config.py as CinBaseConfigClass before the name is rebound to the shared instance.
  • Build a private config with CinBaseConfigClass() in all eight cinbase IMEs: no shared-object reset, no deepcopy.
  • Drop the now-unused import copy.

Each IME still sets imeDirName and cinFileList and calls load() on its own config; the removed deepcopy came from a just-reset object, so a fresh instance starts from the same defaults and behaviour is unchanged.

Validation:

  • python -m compileall python clean on the bundled 32-bit interpreter.
  • A regression check that constructing the checj backend leaves the shared CinBaseConfig untouched fails on master (AssertionError: 3 != 9) and passes on this branch.

Architecture and design by asdf80730. Implementation generated with AI assistance from omp (Qwen3.8-Flash-Next).

python/cinbase/config.py rebinds the CinBaseConfig class name to one
shared module-level instance. Each cinbase backend reset that singleton
with CinBaseConfig.__init__() and then copy.deepcopy()'d it, so
constructing a service snapped the config the configtool reads back to
the constructor defaults, and two backends starting concurrently could
race between the reset and the copy, picking up each other's state.

Export the class before the rebinding as CinBaseConfigClass and let
every cinbase IME build a private instance instead. Behaviour is
unchanged otherwise: each IME still sets imeDirName and cinFileList and
calls load() on its own config right after, and the previous deepcopy
came from a just-reset object, so a fresh instance carries the same
defaults.

Architecture and design by asdf80730. Implementation generated with AI
assistance from omp (Qwen3.8-Flash-Next).
asdf80730 added a commit to asdf80730/PIME that referenced this pull request Oct 27, 2026
Regression coverage for the upstream fix: constructing a cinbase
backend must leave the shared CinBaseConfig singleton untouched, and
configs of separate service instances must not share state. The test
skips itself until the exported CinBaseConfigClass lands in python/,
so it activates once the upstream merge reaches this branch.

Fully generated by omp (Qwen3.8-Flash-Next) without human intervention.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant