Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed

- Bugs in append mode for writing to files in python (#1200)

## [0.29.1] - 2025-02-21

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/PyodideWorker.js
Copy link
Contributor

Choose a reason for hiding this comment

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

are there any tests around this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there aren't I'm afraid, only ones on the UI side, but that's not really testing the inner workings of pyodide

Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const PyodideWorker = () => {
self.content += content
if len(self.content) > MAX_FILE_SIZE:
raise OSError(f"File '{self.filename}' exceeds maximum file size of {MAX_FILE_SIZE} bytes")
with _original_open(self.filename, "w") as f:
with _original_open(self.filename, mode) as f:
f.write(self.content)
basthon.kernel.write_file({ "filename": self.filename, "content": self.content, "mode": mode })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ const PyodideRunner = ({ active, outputPanels = ["text", "visual"] }) => {
updatedContent = content;
} else if (mode === "a") {
updatedContent =
(componentToUpdate ? componentToUpdate.content + "\n" : "") + content;
(componentToUpdate ? componentToUpdate.content : "") + content;
}

if (componentToUpdate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ describe("When file write event is received", () => {
worker.postMessageFromWorker({
method: "handleFileWrite",
filename: "existing_file.txt",
content: "new content",
content: "\nnew content",
mode: "a",
});
expect(dispatchSpy).toHaveBeenCalledWith({
Expand Down Expand Up @@ -364,7 +364,7 @@ describe("When file write event is received", () => {
worker.postMessageFromWorker({
method: "handleFileWrite",
filename: "existing_file.txt",
content: "new content",
content: "\nnew content",
mode: "a",
});
expect(dispatchSpy).toHaveBeenCalledWith({
Expand Down
Loading