A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Fix Windows path encoding for special characters (#3761) (#3768)
devin-ai-integration[bot]3679579c7f14
diff --git a/marimo/_server/file_manager.py b/marimo/_server/file_manager.pyindex 36ab19fece..4174dbec64 100644--- a/marimo/_server/file_manager.py+++ b/marimo/_server/file_manager.py@@ -106,13 +106,14 @@ class AppFileManager:assert self.filename is not Noneself._create_parent_directories(new_filename)try:- os.rename(self.filename, new_filename)+ # Use pathlib.Path for cross-platform path handling+ src_path = pathlib.Path(self.filename)+ dst_path = pathlib.Path(new_filename)+ src_path.rename(dst_path)except Exception as err:raise HTTPException(status_code=HTTPStatus.SERVER_ERROR,- detail="Failed to rename from {0} to {1}".format(- self.filename, new_filename- ),+ detail=f"Failed to rename from {self.filename} to {new_filename}",) from errdef _save_file(diff --git a/tests/_server/test_file_manager.py b/tests/_server/test_file_manager.pyindex 7d0ca4d212..f4252ff870 100644--- a/tests/_server/test_file_manager.py+++ b/tests/_server/test_file_manager.py@@ -1,6 +1,7 @@from __future__ import annotationsimport os+import shutilimport sysimport tempfilefrom typing import Generator@@ -429,3 +430,22 @@ if __name__ == "__main__":assert changed_cell_ids == {"MJUe"}# Clean upos.remove(temp_file.name)+++def test_rename_with_special_chars(app_file_manager: AppFileManager) -> None:+ """Test that renaming files with special characters works."""+ # Create a temporary file+ temp_dir = tempfile.mkdtemp()+ try:+ initial_path = os.path.join(temp_dir, "test.py")+ with open(initial_path, "w") as f:+ f.write("import marimo")+ app_file_manager.filename = initial_path++ # Try to rename to path with special characters+ new_path = os.path.join(temp_dir, "test & space.py")+ app_file_manager.rename(new_path)+ assert app_file_manager.filename == new_path+ assert os.path.exists(new_path)+ finally:+ shutil.rmtree(temp_dir)