python / python/cpython

Clarify os.stat_result.st_mode as int and mention stat earlier in os.stat_result

Offen
#137,970 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

docs
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Documentation

Issue 1: Clarification that st_mode is an int while octal might be expected

Perhaps the description for st_mode here could use a .. note:: reminding the user that it is an int and a conversion to octal might be needed to see a familiar result.

When checking for file permission bits with os.stat() recently, I noticed the value of the st_mode member of the result was not what I expected - running the program on Unix I expected a familiar value such as 755 to appear at the end of the number. The number looked nothing like that and a quick web search told me I'd need to see that same int in octal notation to see the values I expected. This makes perfect sense after I've learned about it, but I figured maybe a note in the member's description could save someone else a web search.

Issue 2 (related): Moving the reference to the stat module earlier in os.stat_result

I'm also aware now that most such operations should involve the stat module instead of manual parsing of the values. The module is only mentioned at the end of the list of object's members (after st_reparse_tag), while for functions like chflags it is mentioned in the function's description. Could it be moved to the description of os.stat_result? If a user comes looking for a specific member of the os.stat_result object, they are most likely done with reading the member's list once they find it and therefore are unlikely to see the current mention of the module.

Thanks for looking into this!

Linked PRs
  • gh-138532

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der in der Issue verlinkten Dokumentation zu os.stat_result.st_mode, überprüfe anschließend die umgebende Member-Liste von os.stat_result und die aktuelle Referenz zu stat-module. Erledigt ist die Aufgabe, wenn dokumentiert ist, dass st_mode ein int ist, dessen vertraute Berechtigungsbits möglicherweise eine Darstellung im Oktalsystem erfordern, und die Anleitung zu stat-module weiter nach vorne verschoben wurde; prüfe vor Beginn den verlinkten PR gh-138532.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.