You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tabulate correctness tests fail when wcwidth is installed #228
The reference tabulate computes column widths with wcwidth when that package is importable and with len(s) otherwise. Our module's default is len(s) (WIDE_CHARS_MODE is opt-in), and the test module's guarded import only shields the reference from the repo's own tabulate/ directory, not from wcwidth.
The two sides therefore apply different rules, and the tables differ:
café (e + combining acute)
ours "café 1" len() = 5
ref "café 1" wcwidth = 4, the combining mark is zero-width
你好
ours width 2 len()
ref width 4 wcwidth, East Asian wide = 2
Measured: wcwidth present (Python 3.10 env, pulled in as a transitive dependency) → 4 failed, 79 passed; wcwidth absent (3.12 env) → 83 passed. CI is green because the CI environment does not install wcwidth.
Fix
Hide wcwidth for the reference import — sys.modules["wcwidth"] = None makes the import fail cleanly, so the reference selects its len(s) path and both sides compute widths the same way in every environment — and add a guard test asserting tabulate.wcwidth is None, so the comparison cannot silently drift back.
This follows the same pattern as the other reference-shadowing fixes (#196 soupsieve 2.10, #205 benchmark references).
Activity
docs(changelog): tabulate reference width mode
docs(changelog):tabulate 参考实现的宽度模式
test(tabulate): compare against the reference's len() width path