Skip to content

fix: name a directory given to Project.save or Project.load - #79

Merged
SMI-Lab-Inha merged 1 commit into
devfrom
fix/project-save-directory
Dec 2, 2026
Merged

SMI-Lab-Inha merged 1 commit into
devfrom
fix/project-save-directory

Conversation

@SMI-Lab-Inha

Copy link
Copy Markdown
Owner

Problem

Project.save given an existing directory wrote its temporary file and then failed in os.replace with PermissionError: [WinError 5] Access is denied on Windows. Project.load given a directory also raised PermissionError on Windows. Linux and macOS raise IsADirectoryError, so the same mistake gave a different, unhelpful error depending on the platform.

Change

  • A private helper, _not_a_directory, checks the path before anything is written or read. It raises IsADirectoryError (errno.EISDIR) naming the method and the path:

    IsADirectoryError: [Errno 21] Project.save needs a project file path, not a directory: '.../results'
    
  • Project.save and Project.load call it first. A missing file still raises the native FileNotFoundError, as before.

Tests

  • New test_save_and_load_name_a_directory_on_every_platform: both methods raise IsADirectoryError with the named message, nothing is written into the directory, and no temporary file is left behind.
  • tests/test_project.py and tests/test_project_v2.py: 105 passed locally (Windows, Python 3.11).
  • ruff check, ruff format --check and mypy pass.
  • The project tests carry no taxonomy marker, so the validation report is unchanged.

Project.save onto an existing directory raised PermissionError (WinError 5)
from the final os.replace on Windows, after writing its temporary file, and
Project.load raised PermissionError there too; other platforms raise
IsADirectoryError. Both now check the path first and raise IsADirectoryError
naming it and the method, on every platform, before anything is written.

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T19:03:30.089178Z fc41294 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: fc412945a7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@read-the-docs-community

Copy link
Copy Markdown

📖 1 file modified


Preview · build overview · CableXSec · built Dec. 2, 2026, 7:03 p.m. UTC

@SMI-Lab-Inha
SMI-Lab-Inha merged commit 85329cd into dev Dec 2, 2026
25 of 27 checks passed
@SMI-Lab-Inha
SMI-Lab-Inha deleted the fix/project-save-directory branch December 3, 2026 05:29
SMI-Lab-Inha added a commit that referenced this pull request Dec 4, 2026
CableXSec 0.2.4: the companion article cited as published, Ocean
Engineering 376, 129821 (#80), and Project.save/load naming a directory
with IsADirectoryError on every platform (#79). Release record:
validation/RELEASE_0_2_4.md.

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant