This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Different behaviour with zipfile
Type: behavior Stage:
Components: Versions: Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, flvn.dev, jaraco
Priority: normal Keywords:

Created on 2021-12-09 10:19 by flvn.dev, last changed 2022-04-11 14:59 by admin.

Messages (5)
msg408104 - (view) Author: flvn.dev (flvn.dev) Date: 2021-12-09 10:19
Given the this directory structure:

```
logs
├── 2020
│  ├── 2020101.zip
|  ├── ...
├── 2021
│  ├── 2021101.zip
|  ├── ...
```

The following piece of code:

```python
from pathlib import Path
from zipfile import Path as ZipPath

for item in Path("logs").iterdir():
    if item.is_dir():
        path = next(item.iterdir())
        print(ZipPath(path).name)

```

gives different results between Python 3.9.7 (empty strings) and 3.10.0 (the zip files name)
msg408138 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-12-09 16:41
What does "path" (the input to ZipPath) look like?

Please change your print statement to:
print(repr(path), ZipPath(path).name)

Then send us the output from each version of python.
msg408338 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-12-11 21:16
Actually, printing out:
print(repr(path), repr(ZipPath(path)))
would be more useful.

If I don't hear back in a few days, I'm going to close this issue.
msg408956 - (view) Author: flvn.dev (flvn.dev) Date: 2021-12-20 12:15
The output of:

```python
print(repr(path), repr(ZipPath(path)))

```

gives this in both versions:

```
PosixPath('logs/2020/2020101.zip') Path('logs/2020/2020101.zip', '')
PosixPath('logs/2021/2021101.zip') Path('logs/2021/2021101.zip', '')
```
msg408971 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-12-20 19:56
It looks like this was changed in https://bugs.python.org/issue42043

@jaraco might have some insights.
History
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90182
2021-12-20 19:56:17eric.smithsetnosy: + jaraco
messages: + msg408971
2021-12-20 12:15:37flvn.devsetmessages: + msg408956
2021-12-11 21:16:40eric.smithsetstatus: pending -> open

messages: + msg408338
2021-12-10 15:12:38eric.smithsetstatus: open -> pending
2021-12-09 16:41:28eric.smithsetnosy: + eric.smith
messages: + msg408138
2021-12-09 10:19:15flvn.devcreate