Skip to content

BUG: When running the setup.py script, a TypeError occurs in the shutil.rmtree() function due to a generator being passed instead of a valid path. #58262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
aabhinavg opened this issue Apr 15, 2024 · 2 comments
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@aabhinavg
Copy link

aabhinavg commented Apr 15, 2024

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

**Steps to Reproduce**:
1. Clone the repository.
2. Navigate to the project directory.
3. Run the `python setup.py clean` script.
4. Observe the error.

Issue Description

Additional Information:
The issue is likely caused by passing a generator instead of a valid path to shutil.rmtree(). The script attempts to iterate over a generator, self._clean_trees, and remove each path using shutil.rmtree(). However, a generator is not a valid input type for shutil.rmtree().

Here's the code snippet demonstrating the issue:

for clean_tree in self._clean_trees:
    try:
        print("The type of input is ", type(clean_tree))
        shutil.rmtree(clean_tree)
    except OSError:
        pass


Please let me know if you need any additional information.


### Expected Behavior

When you run the command ``python setup.py clean`` , you are typically instructing the setup script to remove any temporary files and build artifacts from the project directory.



### Installed Versions

<details>

INSTALLED VERSIONS
------------------
commit                : d8c7e85a1b260f2296ad4b921555b699b3ed3f27
python                : 3.10.14.final.0
python-bits           : 64
OS                    : Darwin
OS-release            : 22.6.0
Version               : Darwin Kernel Version 22.6.0: Wed Jul  5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000
machine               : arm64
processor             : arm
byteorder             : little
LC_ALL                : None
LANG                  : None
LOCALE                : None.UTF-8

pandas                : 3.0.0.dev0+710.gd8c7e85a1b
numpy                 : 1.26.4
pytz                  : 2024.1
dateutil              : 2.9.0
setuptools            : 69.5.1
pip                   : 24.0
Cython                : 3.0.10
pytest                : 8.1.1
hypothesis            : 6.100.1
sphinx                : 7.2.6
blosc                 : None
feather               : None
xlsxwriter            : 3.1.9
lxml.etree            : 5.1.0
html5lib              : 1.1
pymysql               : 1.4.6
psycopg2              : 2.9.9
jinja2                : 3.1.3
IPython               : 8.22.2
pandas_datareader     : None
adbc-driver-postgresql: None
adbc-driver-sqlite    : None
bs4                   : 4.12.3
bottleneck            : 1.3.8
fastparquet           : 2024.2.0
fsspec                : 2024.3.1
gcsfs                 : 2024.3.1
matplotlib            : 3.8.4
numba                 : 0.59.1
numexpr               : 2.9.0
odfpy                 : None
openpyxl              : 3.1.2
pyarrow               : 15.0.2
pyreadstat            : 1.2.7
python-calamine       : None
pyxlsb                : 1.0.10
s3fs                  : 2024.3.1
scipy                 : 1.13.0
sqlalchemy            : 2.0.29
tables                : 3.9.2
tabulate              : 0.9.0
xarray                : 2024.3.0
xlrd                  : 2.0.1
zstandard             : 0.22.0
tzdata                : 2024.1
qtpy                  : None
pyqt5                 : None

</details>
@aabhinavg aabhinavg added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 15, 2024
@aabhinavg
Copy link
Author

/take

@aabhinavg
Copy link
Author

The patch can be found here: link to the patch.

This patch iterates through each path provided by the generator self._clean_trees and processes them individually with shutil.rmtree() , which improves error handling and avoids passing the generator directly.

Please review and consider merging this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant