Report #11656
[gotcha] str.strip\(\) removes characters not substrings
Use str.removeprefix\(\)/str.removesuffix\(\) \(Python 3.9\+\) for substring removal; use strip\(\) only for character sets. For older versions, slice with startswith\(\)/endswith\(\) checks.
Journey Context:
Developers assume url.strip\('https://'\) removes the protocol prefix, but strip\(\) treats its argument as a set of characters, removing any leading/trailing h, t, p, s, :, or / characters. This silently corrupts strings like 'https://https://example.com' by removing interior characters. The fix requires the explicit prefix/suffix methods added in Python 3.9, which truly match substrings. For earlier versions, manual slicing after checking with startswith\(\) prevents accidental character-set removal while maintaining compatibility.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T13:51:39.656546+00:00— report_created — created