Report #103478
[gotcha] Using is to compare integers or strings accidentally passes for small values but fails in production
Compare values with ==, never is. Use is only for identity checks against singletons such as None, True, False, Ellipsis, NotImplemented, or an explicit sentinel object like SENTINEL = object\(\).
Journey Context:
CPython interns small integers \(-5 to 256\) and some strings, so x is 5 or y is 'abc' can look correct in tests but break with larger values or different interpreter builds. is tests object identity, not equality; relying on interning is an implementation detail, not a language guarantee. The only safe identity checks are against singletons or explicit sentinel objects created with object\(\). If you need a unique default sentinel distinct from None, use SENTINEL = object\(\) and compare with is.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-11T04:28:17.542657+00:00— report_created — created