Skip to content

♻️ Refactor: Missing UTF-8 encoding in file open#439

Open
tang-vu wants to merge 1 commit intolepture:mainfrom
tang-vu:contribai/refactor/missing-utf-8-encoding-in-file-open
Open

♻️ Refactor: Missing UTF-8 encoding in file open#439
tang-vu wants to merge 1 commit intolepture:mainfrom
tang-vu:contribai/refactor/missing-utf-8-encoding-in-file-open

Conversation

@tang-vu
Copy link
Copy Markdown

@tang-vu tang-vu commented Mar 20, 2026

♻️ Refactoring

Problem

The open(filepath, "r") call does not specify an encoding. In Python, this defaults to the system's default encoding (e.g., cp1252 on Windows). If the Markdown files contain emojis or other non-ASCII characters, this will raise a UnicodeDecodeError on those platforms.

Severity: medium
File: benchmark/bench.py

Solution

Explicitly specify the encoding by changing the line to: with open(filepath, "r", encoding="utf-8") as f:

Changes

  • benchmark/bench.py (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

🤖 About this PR

This pull request was generated by ContribAI, an AI agent
that helps improve open source projects. The change was:

  1. Discovered by automated code analysis
  2. Generated by AI with context-aware code generation
  3. Self-reviewed by AI quality checks

If you have questions or feedback about this PR, please comment below.
We appreciate your time reviewing this contribution!

The `open(filepath, "r")` call does not specify an encoding. In Python, this defaults to the system's default encoding (e.g., `cp1252` on Windows). If the Markdown files contain emojis or other non-ASCII characters, this will raise a `UnicodeDecodeError` on those platforms.


Affected files: bench.py
@sonarqubecloud
Copy link
Copy Markdown

@naoNao89
Copy link
Copy Markdown

naoNao89 commented Mar 27, 2026

u should stop using AI for trivial pr. this useless bench read file refactor assumes no one designs files bench contain complex chars like Chinese, emoji

@tang-vu
Copy link
Copy Markdown
Author

tang-vu commented Mar 27, 2026

u should stop using AI for trivial pr. this useless bench read file refactor assumes no one designs filenames with complex chars like Chinese names ...

If you have too much free time, just cry by yourself, lè nhà lè nhè Syu Ng ạ

@hahahahacker2009
Copy link
Copy Markdown

hahahahacker2009 commented Mar 27, 2026

Thắng sao được trùm AI, xoá comment nhanh còn kịp

@tang-vu
Copy link
Copy Markdown
Author

tang-vu commented Mar 27, 2026

Thắng sao được trùm AI, xoá comment nhanh còn kịp :)

Cứ thế thôi, đây là cả 1 hội rủ nhau bait à

Copy link
Copy Markdown

@naoNao89 naoNao89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close pls

else:
filepath = os.path.join(ROOT_DIR, "cases", filename)
with open(filepath, "r") as f:
with open(filepath, "r", encoding="utf-8") as f:
Copy link
Copy Markdown

@naoNao89 naoNao89 Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bro, these bench files havent changed in 4 years and CI is been green, this just benchmarks markdown rendering (### headers, links, >, ..) not Chinese text or emoji parsing

pure ai slop. close pls

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do professional mourners get paid for their work? Can I work with you?

@hahahahacker2009
Copy link
Copy Markdown

Thắng sao được trùm AI, xoá comment nhanh còn kịp

Cứ thế thôi, đây là cả 1 hội rủ nhau bait à

Ko, em ghét thằng kia lắm ạ, cứ dùng AI code rồi tưởng mình thượng đẳng

@tang-vu
Copy link
Copy Markdown
Author

tang-vu commented Mar 27, 2026

close pls

Nhắc lại từ facebook nhé người đẹp
có phải do người đẹp không được tôi rep nên lè nhè từ sáng đến tối không, ngốc ngếch đáng yêu thật, pull từ 8 ngày trước là lúc release 0.x.0 ai chia sẻ công khai với người đẹp chưa mà người đẹp giãy nảy lên thế, với giờ tôi cũng không rep ẩn danh với clone làm gì, người đẹp lôi acc chính vào trang cá nhân tôi mình hàn huyên tâm sự nhé.

@tang-vu
Copy link
Copy Markdown
Author

tang-vu commented Mar 27, 2026

Thắng sao được trùm AI, xoá comment nhanh còn kịp

Cứ thế thôi, đây là cả 1 hội rủ nhau bait à

Ko, em ghét thằng kia lắm ạ, cứ dùng AI code rồi tưởng mình thượng đẳng

A đoán nhé, là nhóc kia 2k9 thật à, chứ người trưởng thành ai rảnh đâu mà chăm chỉ vác tù và hàng tổng vậy, kể cả người toxic người ta cũng chẳng rảnh vậy.

@hahahahacker2009
Copy link
Copy Markdown

hahahahacker2009 commented Mar 27, 2026

Thắng sao được trùm AI, xoá comment nhanh còn kịp

Cứ thế thôi, đây là cả 1 hội rủ nhau bait à

Ko, em ghét thằng kia lắm ạ, cứ dùng AI code rồi tưởng mình thượng đẳng

A đoán nhé, là nhóc kia 2k9 thật à, chứ người trưởng thành ai rảnh đâu mà chăm chỉ vác tù và hàng tổng vậy, kể cả người toxic người ta cũng chẳng rảnh vậy.

E bị nó chửi ác lắm anh ơi 😭🤬 ko đùaa

@tang-vu
Copy link
Copy Markdown
Author

tang-vu commented Mar 27, 2026

Thắng sao được trùm AI, xoá comment nhanh còn kịp

Cứ thế thôi, đây là cả 1 hội rủ nhau bait à

Ko, em ghét thằng kia lắm ạ, cứ dùng AI code rồi tưởng mình thượng đẳng

A đoán nhé, là nhóc kia 2k9 thật à, chứ người trưởng thành ai rảnh đâu mà chăm chỉ vác tù và hàng tổng vậy, kể cả người toxic người ta cũng chẳng rảnh vậy.

E bị nó chửi ác lắm anh ơi 😭🤬 ko đùaa

Vui mà, nhiệt tình, nói chung là cũng k ghét lắm, chỉ là hơi phiền thôi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants