removesuffix helper returns an empty string for an empty suffix
還沒有人認領這個 Issue。
評估
研究方向
從 src/browserbase/_utils/_utils.py:368-375 開始,檢查 removesuffix 的實作以及相關的前綴輔助函式。執行現有的測試套件,然後為前綴和後綴為空字串的情況新增覆蓋;當 removesuffix("abc", "") 回傳 "abc" 且與標準函式庫的行為一致時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Description
The internal removesuffix helper claims to backport str.removesuffix, but it returns an empty string when the requested suffix is empty.
Code reference
src/browserbase/_utils/_utils.py:368-375
The implementation executes string[:-len(suffix)]; for an empty suffix this becomes string[:-0], which is string[:0].
Reproduction
from browserbase._utils._utils import removesuffix
print(repr(removesuffix("abc", "")))
print(repr("abc".removesuffix("")))
Actual:
''
'abc'
Expected behavior
To match the documented stdlib behavior, an empty suffix should leave the original string unchanged.
Why it matters
This shared helper silently corrupts input for a valid edge case and has no direct test coverage. Even though current in-repo call sites are limited, it is exported through browserbase._utils and may be reused by generated or manual code later. The fix is small (if suffix and string.endswith(suffix): ...) and should include empty-string tests for both prefix/suffix helpers.
- 主要語言
- Python
- 星號
- 93
- 分支
- 16
- 平均合併
- 11 分鐘
- 30 天內合併 PR
- 3
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
browserbase/sdk-python 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 84/100
browserbase/sdk-python#180 ·
-
難度 2/5 1-3 小時 新手友好度 82/100
browserbase/sdk-python#179 ·
-
難度 2/5 1-3 小時 新手友好度 78/100
browserbase/sdk-python#178 ·
-
難度 2/5 1-3 小時 新手友好度 82/100
browserbase/sdk-python#176 ·
-
難度 2/5 1-3 小時 新手友好度 82/100
browserbase/sdk-python#175 ·
查看 browserbase/sdk-python 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 88/100
-
難度 2/5 1-3 小時 新手友好度 82/100
-
難度 2/5 1-3 小時 新手友好度 78/100
-
enhancement
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 74/100