Skip to content
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

3 fields are labelled "unnamed field" in repr(scandir.DirEntry.stat()) #140

Open
moreati opened this issue Aug 12, 2022 · 3 comments
Open

Comments

@moreati
Copy link

moreati commented Aug 12, 2022

Using current master (rev 34a0cc1) the last 3 fields are mislabelled as unnamed field

(v) $ pip install git+https://github.com/benhoyt/scandir.git                        
...
Successfully installed scandir-1.10.1
(v) $ python3 -c"import scandir; print(list(scandir.scandir('.'))[0].stat())"
scandir.stat_result(st_mode=16877, st_ino=5942134, st_dev=16777229, st_nlink=12, st_uid=501, st_gid=20, st_size=384, unnamed field=1637099040, unnamed field=1637099040, unnamed field=1637099040)

using the most recent PyPI release they're labelled as expected (st_atime, ...)

(v) $ pip install scandir==1.10.0                                            
...
      Successfully uninstalled scandir-1.10.1
Successfully installed scandir-1.10.0
(v) $ python3 -c"import scandir; print(list(scandir.scandir('.'))[0].stat())"
os.stat_result(st_mode=16877, st_ino=5045619, st_dev=16777229, st_nlink=9, st_uid=501, st_gid=20, st_size=288, st_atime=1660286912, st_mtime=1660286842, st_ctime=1660286842)

System details, just incase

(v) $ python --version
Python 3.10.5
(v) $ uname -a        
Darwin kintha 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:22 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T6000 arm64
@moreati
Copy link
Author

moreati commented Aug 12, 2022

I believe the behaviour was introduced in #137. I don't (yet) know what a fix would look like, I'll update if I figure something out.

I happened to come across it while trying something similar for https://github.com/moreati/scanwalk (not ready for use by anyone, just a toy for now), specifically https://github.com/moreati/scanwalk/tree/franken-posixmodule

@benhoyt
Copy link
Owner

benhoyt commented Aug 12, 2022

Thanks for the report. This is strange. Yeah, it's got to be due to #137, but I can't see how just changing that "unnamed field" string to const and renaming it could cause a behavioral difference. If this is important to you, feel free to dig in and come up with a fix. Would be interesting to see if this happens on Linux too.

I have limited time (and desire) to work on scandir these days, now that it's included in Python itself (has been since 3.5). Another approach would be to switch to using os.scandir directly (you may have to monkey-patch if it's a 3rd party library that's using scandir).

@moreati
Copy link
Author

moreati commented Aug 12, 2022

I've no pressing need for a fix, sorry for not making that clear. This report was mainly so people had a reference in case they hit it too. Thanks for shipping scandir all these years.

Confirm it also happens on Linux

(v) pi@rpi1:~/src $ python3 -c"import scandir; print(list(scandir.scandir('.'))[0].stat())"
scandir.stat_result(st_mode=16877, ..., unnamed field=1657451693, unnamed field=1657456796, unnamed field=1657456796)

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

No branches or pull requests

2 participants