removesuffix helper returns an empty string for an empty suffix

未關閉 適合新手
#182 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
82/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
冷清
技術堆疊
python
領域
tooling

研究方向

從 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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

browserbase/sdk-python 的其他 Issue

查看 browserbase/sdk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。