I believe appdirs does not conform to the XDG spec when environment variables exist, but are empty.
The XDG spec says:
If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.
However, the implementation here uses path = os.getenv('XDG_DATA_HOME', os.path.expanduser("~/.local/share")), which is correct when the environment variable does not exist, but incorrect when it exists but is empty.
I propose a helper function like
def getenv(name, default=None):
value = os.getenv(name)
if not value:
value = default
return value
and using that wherever os.getenv is currently used.
This is a breaking change, but necessary for conformance with the XDG spec.
I believe
appdirsdoes not conform to the XDG spec when environment variables exist, but are empty.The XDG spec says:
However, the implementation here uses
path = os.getenv('XDG_DATA_HOME', os.path.expanduser("~/.local/share")), which is correct when the environment variable does not exist, but incorrect when it exists but is empty.I propose a helper function like
and using that wherever
os.getenvis currently used.This is a breaking change, but necessary for conformance with the XDG spec.