pypi platformdirs 4.14.0

3 hours ago

Features

  • Accept a keyword-only ensure_exists in the module-level media directory functions, such as user_documents_path, to create a directory set through XDG_*_DIR or user-dirs.dirs (#656) by @darrenhuai and @gaborbernat.

Bug fixes

  • Return the media and fonts directories under root's home for root with use_site_for_root, ignoring the invoking user's XDG_*_DIR, user-dirs.dirs and XDG_DATA_HOME, and create no inherited media directory under ensure_exists (#661) by @gaborbernat.
  • Raise ValueError from site_data_dir and site_config_dir under multipath=True when appname or version contains os.pathsep, rather than returning a string that splits into a directory outside the site base (#662) by @gaborbernat.
  • Parse an unquoted user-dirs.dirs value with a long run of blanks in linear time, rather than in time quadratic in the run's length on every Unix media directory lookup (#663) by @gaborbernat.
  • Treat a relative HOME as unset on Unix, macOS and iOS, taking the home from the password database or raising RuntimeError, rather than resolving user directories against the working directory (#664) by @gaborbernat.
  • Refuse a symlink as XDG_RUNTIME_DIR in user_runtime_dir when the value ends with / or /., which made the check follow the link (#665) by @gaborbernat.
  • Redirect user_*_dir calls with use_site_for_root=True when the effective uid is 0, so a setuid-root process gets the site directories, and name and check the runtime directory by the effective uid (#666) by @gaborbernat.
  • Apply the XDG_RUNTIME_DIR check of the Unix user_runtime_dir to the macOS one, so it no longer uses a directory that is a symlink, owned by another user or not mode 0700 (#667) by @gaborbernat.
  • Reject an XDG_RUNTIME_DIR below a parent that another user can replace, such as their own entry in /tmp, instead of creating the runtime directory through it (#668) by @gaborbernat.
  • Stop accepting a Unix runtime directory that another user creates between the owner check and its use: ensure_exists and place_runtime_file create it before checking it, and find_runtime_file checks it again after a hit (#669) by @gaborbernat.
  • Raise PermissionError on macOS when ensure_exists would create the site cache through a /Library/Caches/$appname that is a symlink, not a directory, or owned by a user other than root and the current one (#670) by @gaborbernat.
  • With ensure_exists, raise FileExistsError when a configured media directory such as user_documents_dir is a regular file or a symlink to one, instead of returning the file's path. Dangling symlinks are still returned unchanged (#672) by @rupayon123 and @gaborbernat.

New Contributors

PyPI release

Full Changelog

Don't miss a new platformdirs release

NewReleases is sending notifications on new releases.