Skip to content

BUG: website builder deletes source files when --target-path equals source_path #70082

Description

@studentarijitpaul

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

The following reproduces the issue on Windows PowerShell.

First, create a copy of the website source:


Copy-Item -Recurse web\pandas "$env:TEMP\pandas-web-test"


Verify that the source files exist:


Test-Path "$env:TEMP\pandas-web-test\config.yml"
# True

Test-Path "$env:TEMP\pandas-web-test\versions.json"
# True


Then use the same directory as both `source_path` and `--target-path`:


python web\pandas_web.py "$env:TEMP\pandas-web-test" --target-path "$env:TEMP\pandas-web-test"

Issue Description

The website builder deletes the source directory contents when
--target-path is the same directory as source_path.

I reproduced this using a fresh copy of web/pandas.

Before running the command, both config.yml and versions.json were
present in the source directory.

I then ran:

python web\pandas_web.py "$env:TEMP\pandas-web-test" --target-path "$env:TEMP\pandas-web-test"

The command failed with:

FileNotFoundError: ...\pandas-web-test\config.yml

After the command completed, both config.yml and versions.json were
no longer present in the source directory.

The relevant code in web/pandas_web.py is:

config_fname = source_path / "config.yml"

shutil.rmtree(target_path, ignore_errors=True)
os.makedirs(target_path, exist_ok=True)

...

context = get_context(config_fname, target_path=target_path)

When source_path and target_path refer to the same directory,
shutil.rmtree() removes the source files before config.yml is later
read.

Expected behavior:
The builder should detect that the source and target directories
overlap before deleting anything and reject the operation with a
clear error message.

I used ChatGPT (GPT-5.6 Luna) to assist with investigating the code
path and drafting this issue. I reproduced and verified the behavior
myself.

Expected Behavior

The website builder should detect that the source and target directories overlap before deleting anything.

It should reject the operation with a clear error message instead of deleting the source files.

Installed Versions

Details

Python: 3.14.7
Installed pandas package: 3.0.6
Repository commit: 92b072c
Branch: main
OS: Windows

Note: pd.show_versions() could not be run because importing the local pandas development checkout requires compiled extensions that are not currently built (pandas._libs.pandas_parser was not available).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugCIContinuous Integration

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions