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

Failure with DEBUG logging + no 'tld_set_snapshot' + no 'cache_file' #194

Closed
dml37 opened this issue Mar 20, 2020 · 3 comments
Closed

Failure with DEBUG logging + no 'tld_set_snapshot' + no 'cache_file' #194

dml37 opened this issue Mar 20, 2020 · 3 comments
Labels
help wanted contributions welcome, submit a PR

Comments

@dml37
Copy link

dml37 commented Mar 20, 2020

If the app with Tldextract runs
a) without the 'tld_set_snapshot' file
b) the logging is in DEBUG mode
c) there is no previously created 'cache_file' in the TLDEXTRACT_CACHE - defined location
then the application fails.

It looks like the failure is in the below code which, in this specific case, tries to get data from 'tld_set_snapshot' file which does not exists.

Workaround:
Switching logging to INFO causes the lib to download the fresh copy of 'cache_file' and it all works fine.

def _cache_tlds(self, tlds):
    '''Logs a diff of the new TLDs and caches them on disk, according to
    settings passed to __init__.'''
    if LOG.isEnabledFor(logging.DEBUG):
        import difflib
        snapshot_data = pkgutil.get_data(__name__, '.tld_set_snapshot')
        snapshot = sorted(json.loads(snapshot_data.decode('utf-8')))
        new = sorted(tlds)
        LOG.debug('computed TLD diff:\n%s', '\n'.join(difflib.unified_diff(
            snapshot,
            new,
            fromfile=".tld_set_snapshot",
            tofile=self.cache_file
        )))
@floer32
Copy link
Collaborator

floer32 commented Mar 23, 2020

Want to submit a PR?

@floer32 floer32 added the help wanted contributions welcome, submit a PR label Mar 23, 2020
@john-kurkowski
Copy link
Owner

Can you show the full error? Got a minimal, reproducible example?

Why would there be no such file? It's included in the package. In source control even.

@john-kurkowski
Copy link
Owner

Haven't heard back.

As of #207, there's no more debug log. This probably won't reoccur. Not sure what the exact failure was though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted contributions welcome, submit a PR
Projects
None yet
Development

No branches or pull requests

3 participants