Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

os.remove() does not remove files in a sub-directory #95758

Copy link
Copy link
Closed
@pjfarley3

Description

@pjfarley3
Issue body actions

Bug report

Using os.remove() to remove multiple files in a subdirectory using an absolute path does not work in multiple linux environments, including z/OS Unix, Ubuntu Linux 20.04 under Windows WSL, and Ubuntu Linux 20.04 in VIrtualBox under Windows.

In each environment, the attempt was made to accomplish a multiple-file remove from a directory as follows:

os.remove("/abs/path/to/currdir/contest/*")

Where "/abs/path/to/currdir" is returned from os.getcwd() and path separators are added via os.sep.

Also tested was using subprocess.run to execute an "rm" command (with no flags) to remove the same files followed by an "rmdir" command to remove the directory, and both of those also fail to remove the files as requested and therefore the directory since it is not empty.

In all cases, performing the equivalent "rm" and "rmdir" commands from a shell prompt or from a shell script directly (rather than from inside a python program) succeed as expected.

Shell script and python script demonstrating the issue are attached, along with logs of output from the three environments tested.

My environments

  • CPython versions tested on:

  • python 3.9.5 on z/OS Unix

  • python 3.8.10 on Ubuntu 20.04 (WSL and VirtualBox)

  • Operating system and architecture:

  • z/OS V2.4 (IBM Zxplore system, available free online at https://ibmzxplore.influitive.com/)

  • Ubuntu 20.04 LTS under Windows WSL

  • Ubuntu 20.04 LTS under VirtualBox 6.1.30 on Windows 10 64 Pro

uname and python version outputs follow.

z/OS Unix:
/z/zxxxxx > uname -a
OS/390 S0W1 27.00 04 3906
/z/zxxxxx > python3 -V
Python 3.9.2

WSL Ubuntu:
userid@DESKTOP:~$ uname -a
Linux DESKTOP 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux
userid@DESKTOP:~$ python3 -V
Python 3.8.10

VirtualBox Ubuntu:
userid@Ubuntu20:~$ uname -a
Linux Ubuntu20 5.15.0-43-generic #46~20.04.1-Ubuntu SMP Thu Jul 14 15:20:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
userid@Ubuntu20:~$ python3 -V
Python 3.8.10

Attaching shell and python scripts here as *.txt files, rename to execute:

testosfnc.sh.txt

testosfnc.py.txt

Logs from each tested environment:

z/OS Unix:
testosfnc.zos.log

WSL Ubuntu:
testosfnc.wslubu.log

VirtualBox Ubuntu:
testosfnc.vbxubu.log

Please also CC me at pjfarley3 at earthlink dot net for any questions or updates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.