gh-127196: Fix crash in `_interpreters`, when `shared` had invalid encodings (GH-127220)
(cherry picked from commit 087bb48aca)
Co-authored-by: sobolevn <mail@sobolevn.me>
gh-126654: Fix crash in several functions in `_interpreters` module (GH-126678)
(cherry picked from commit 9fc2808eaf)
Co-authored-by: sobolevn <mail@sobolevn.me>