チケット #43930

generate_packets.py: Use pathlib for file path handling

登録: 2022-02-19 22:21 最終更新: 2022-02-22 21:10

報告者:
担当者:
チケットの種類:
状況:
完了
コンポーネント:
マイルストーン:
優先度:
5 - 中
重要度:
5 - 中
解決法:
修正済み
ファイル:
1

詳細

Part of #43927. Using pathlib allows for clean, filesystem-agnostic handling of paths.

チケットの履歴 (7 件中 3 件表示)

2022-02-19 22:21 更新者: alienvalkyrie
  • 新しいチケット "generate_packets.py: Use pathlib for file path handling" が作成されました
2022-02-20 11:58 更新者: alienvalkyrie
  • 担当者(未割り当て) から alienvalkyrie に更新されました
  • マイルストーン3.1.0 (完了済み) から 3.2.0 に更新されました
  • コンポーネントGeneral から Bootstrap に更新されました
2022-02-20 13:15 更新者: alienvalkyrie
  • 解決法なし から 受領 に更新されました
コメント

In addition to cleaning up parts of the code, this patch finally makes it possible to run the script on Windows without running into issues due to mixed path separators.

2022-02-20 14:03 更新者: cazfi
コメント

Reply To alienvalkyrie

In addition to cleaning up parts of the code, this patch finally makes it possible to run the script on Windows without running into issues due to mixed path separators.

I assume that by "path separators" you mean separator between a directory and its subdirectory, not separator between entire paths like in PATH environment variable and the like.

Is there a risk that this *introduces* mixed dir separators? The build system runs it with parameters given with '/' separator. If it then appends to that with '\' separators, the resulting path will contain both.

2022-02-20 21:14 更新者: alienvalkyrie
コメント

Reply To cazfi

Reply To alienvalkyrie

In addition to cleaning up parts of the code, this patch finally makes it possible to run the script on Windows without running into issues due to mixed path separators.

I assume that by "path separators" you mean separator between a directory and its subdirectory, not separator between entire paths like in PATH environment variable and the like.

Yes, thank you. "path separators" was the wrong word to use there.

Is there a risk that this *introduces* mixed dir separators? The build system runs it with parameters given with '/' separator. If it then appends to that with '\' separators, the resulting path will contain both.

There is not – that kind of issue is precisely what pathlib is designed to handle. Since Windows file and directory names aren't allowed to contain slashes anyway, those are safely parsed as separating directories (in fact, until the point where a path is given to the OS or otherwise turned into a plain string, I believe slashes are used internally even for Windows paths).

To be sure, I tested the script on both Windows and Linux – on Windows, the verbose log messages (where paths are stringified) have backslashes in them (even where the build system passed paths with slashes, since every path passes through pathlib), but apart from that, everything is identical.

(編集済, 2022-02-20 21:15 更新者: alienvalkyrie)
2022-02-22 21:10 更新者: alienvalkyrie
  • 状況オープン から 完了 に更新されました
  • 解決法受領 から 修正済み に更新されました

編集

このチケットにコメントを追加するには、ログインが必要です » ログインする