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

[CodeStyle] use built-in open instead of io.open #46751

Merged
merged 2 commits into from
Oct 11, 2022

Conversation

SigureMo
Copy link
Member

@SigureMo SigureMo commented Oct 5, 2022

PR types

Others

PR changes

Others

Describe

使用 built-in open 替换 io.open

同样是一个 Python2 历史遗留问题,在 Python2 openio.open 不同,而在 Python3 openio.open 完全相同,也更推荐使用 open 而不是 io.open

@@ -67,7 +66,7 @@ RE_SHEBANG = re.compile(r"^[ \t\v]*#[ \t]?\!")
def _check_copyright(path):
head=[]
try:
with open(path) as f:
with open(path, 'r', encoding='utf-8') as f:
Copy link
Member Author

Choose a reason for hiding this comment

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

这里没有指定编码会在 Windows 上因为编码错误而无法提交,见 cattidea/paddle-flake8-project#66 (comment)

@paddle-bot
Copy link

paddle-bot bot commented Oct 5, 2022

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@luotao1 luotao1 merged commit 75528ad into PaddlePaddle:develop Oct 11, 2022
@SigureMo SigureMo deleted the py2/fix/io-open branch October 11, 2022 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants