john-kurkowski / john-kurkowski/tldextract

Deprecate or remove use __file__

Open
#196 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2k
Forks
219
PR merge metrics
No merged PRs in 30d

Description

For reading `.tld_set`, `__file__` should be replaced with pkgutil.get_data, which is used for `.tld_set_snapshot`.

The dataset file may have been placed into the package data via another means, and the attribute `__file__` may not be present at all, as it is an optional attribute of the Python module loading system. tldextract fails badly atm when it is missing. An example of when it is missing is PyOxidizer, and Nuitka also has similar problems.

When it is missing, or when the package directory is not writable, the cache should be stored in a different location without a warning.

Currently I see the following for every invocation which imports tldextract, because it is installed as a system package used by system apps:

> WARNING unable to cache TLDs in file /usr/lib/python3.8/site-packages/tldextract/.tld_set: [Errno 13] Permission denied: '/usr/lib/python3.8/site-packages/tldextract/.tld_set'

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.