pallets-eco/cachelib

The use of os.replace(...) does not work in Python 2

rayluo opened this issue · 2 comments

It has been reported in here and there that the os.replace(...) used by cachelib is not supported in Python 2. Do we consider to have a fallback implementation for Python 2? Something like this? I can provide a PR if necessary.

try:
    os.replace(tmp, filename)
except AttributeError:  # Python 2 workaround
    try:
        os.remove(filename)
    except:
        pass
    os.rename(tmp, filename)

Python 2 is no longer supported. It looks like you've linked to an issue about an Azure example. I'd strongly encourage them to upgrade their example to use Python 3.6 or newer.

Just for the record, that Azure web app sample does NOT need any upgrade to be used with Python 3. It is already written in a way that it does not use any Python3-or-Python2-only syntax. I was merely shifting the conversation from that issue into its root cause here, to let you decide how/whether you want to satisfy your Python2 customer.