Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Ensure UTF-8 encoding in all 'open()' statements #5818

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

sepehrrasooli
Copy link

Why are these changes needed?

This PR ensures consistent UTF-8 encoding across all file operations by adding encoding="utf-8" to all with open() statements.
This prevents potential encoding issues when running the code in different environments.

Related issue number

Closes #5566

Checks

@sepehrrasooli
Copy link
Author

@sepehrrasooli please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.35%. Comparing base (a701e3b) to head (82936b4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5818   +/-   ##
=======================================
  Coverage   75.35%   75.35%           
=======================================
  Files         177      177           
  Lines       11421    11421           
=======================================
  Hits         8606     8606           
  Misses       2815     2815           
Flag Coverage Δ
unittests 75.35% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sepehrrasooli
Copy link
Author

sepehrrasooli commented Mar 6, 2025

@rysweet Hey, I saw that the conflicts were resolved earlier—thanks for that! I fixed the new ones yesterday. Let me know if there’s anything else I should do before review!

@jackgerrits
Copy link
Member

jackgerrits commented Mar 6, 2025

Why explicitly specify utf-8 and not rely on the default behavior? https://docs.python.org/3/library/functions.html#open

In text mode, if encoding is not specified the encoding used is platform-dependent: locale.getencoding() is called to get the current locale encoding.

EDIT: Hmm I can see the merit of just going all in on utf-8 https://peps.python.org/pep-0597/

@sepehrrasooli
Copy link
Author

Why explicitly specify utf-8 and not rely on the default behavior? https://docs.python.org/3/library/functions.html#open

In text mode, if encoding is not specified the encoding used is platform-dependent: locale.getencoding() is called to get the current locale encoding.

EDIT: Hmm I can see the merit of just going all in on utf-8 https://peps.python.org/pep-0597/

Agreed! Explicitly setting UTF-8 ensures consistency across platforms. Let me know if any changes are needed.

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.

open needs encoding='utf-8' for non-english environment, error in playwright_controller.py
3 participants