Skip to content

Commit 7836164

Browse files
sd2kclaude
authored andcommitted
fix: use Path::to_str instead of display for compiler paths
Path::display() does a lossy conversion which can cause subtle, hard-to-diagnose failures when passing paths to compiler commands. Use to_str() with explicit error handling instead, as suggested in PR review. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3faa0cb commit 7836164

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

build.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,20 @@ fn write_setup_local(cpython_wasi_dir: &Path) -> Result<()> {
391391
// The _sqlite3 module source files (relative to Modules/)
392392
// These are the files that make up the _sqlite3 extension in CPython 3.14
393393
// Note: blob.c is required - it defines pysqlite_close_all_blobs and pysqlite_blob_setup_types
394+
let include_dir = deps_dir.join("include");
395+
let lib_dir = deps_dir.join("lib");
394396
let setup_local_content = format!(
395397
r#"# Auto-generated by build.rs for SQLite support
396398
# Enable _sqlite3 module with statically linked SQLite
397399
398400
_sqlite3 _sqlite/blob.c _sqlite/connection.c _sqlite/cursor.c _sqlite/microprotocols.c _sqlite/module.c _sqlite/prepare_protocol.c _sqlite/row.c _sqlite/statement.c _sqlite/util.c -I{include} -L{lib} -lsqlite3
399401
"#,
400-
include = deps_dir.join("include").display(),
401-
lib = deps_dir.join("lib").display(),
402+
include = include_dir
403+
.to_str()
404+
.ok_or_else(|| anyhow!("non-UTF8 path: {}", include_dir.display()))?,
405+
lib = lib_dir
406+
.to_str()
407+
.ok_or_else(|| anyhow!("non-UTF8 path: {}", lib_dir.display()))?,
402408
);
403409

404410
// Create the Modules directory if it doesn't exist

0 commit comments

Comments
 (0)