Skip to content

Commit

Permalink
Apparently python 2 does not have lru_cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arusekk committed Oct 27, 2020
1 parent 40b0158 commit 681be12
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pwnlib/update.py
Expand Up @@ -27,7 +27,6 @@
import os
import time

from functools import lru_cache
from six.moves.xmlrpc_client import ServerProxy

import packaging.version
Expand Down Expand Up @@ -67,7 +66,6 @@ def read_update_config(settings):

register_config('update', read_update_config)

@lru_cache
def available_on_pypi(prerelease=current_version.is_prerelease):
"""Return True if an update is available on PyPI.
Expand All @@ -76,8 +74,12 @@ def available_on_pypi(prerelease=current_version.is_prerelease):
>>> available_on_pypi(prerelease=False).is_prerelease
False
"""
client = ServerProxy('https://pypi.python.org/pypi')
versions = client.package_releases('pwntools', True)
versions = getattr(available_on_pypi, 'cached', None)
if versions is None:
client = ServerProxy('https://pypi.python.org/pypi')
versions = client.package_releases('pwntools', True)
available_on_pypi.cached = versions

versions = map(packaging.version.Version, versions)

if not prerelease:
Expand Down

0 comments on commit 681be12

Please sign in to comment.