removesuffix helper returns an empty string for an empty suffix

Đang mở Phù hợp với người mới
#182 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu tại src/browserbase/_utils/_utils.py:368-375 và kiểm tra triển khai của removesuffix cùng với helper xử lý prefix liên quan. Chạy test suite hiện có, sau đó bổ sung coverage cho các trường hợp prefix và suffix là chuỗi rỗng; hoàn tất khi removesuffix("abc", "") trả về "abc" và khớp với hành vi của standard library.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
93
Fork
16
Merge trung bình
11 phút
Pull request đã merge (30 ngày)
3

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của browserbase/sdk-python

Tất cả issue của browserbase/sdk-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.