decalage2 / oletools

oletools - python tools to analyze MS OLE2 files (Structured Storage, Compound File Binary Format) and MS Office documents, for malware analysis, forensics and debugging.
http://www.decalage.info/python/oletools
Other
2.92k stars 563 forks source link

Deprecate python2, clarify minimal python3 version #470

Open christian-intra2net opened 5 years ago

christian-intra2net commented 5 years ago

Is your feature request related to a problem? Please describe. Python 2 has an official end of life in less than half a year. See the python countdown

Describe the solution you'd like Have you thought about deprecating support for python2 around that time? Would certainly make development easier if we do not have to constantly think about "Does this also work in python2?" or "What if str here can only do ascii but contains unicode"?

Additional context Also, there are quite some differences between versions of python3. Many python packages do not support python 3.1, some support only python >= 3.4 .

Adding a warning in time about when people have to switch and what version to switch to could make the transition easier.

Describe alternatives you've considered Maintaining python 2 support for too long only encourages people to use an outdated and increasinly insecure python.

decalage2 commented 5 years ago

Indeed I plan to stop supporting Python 2 once it is end of life. (although I spent almost 20 years using it, so it's always hard to stop ;-)

As for Python 3, in setup.py classifiers, we only show 3.4+. Do you mean setup.py should explicitly check that the python version is 3.4+, and display a warning if not?

christian-intra2net commented 5 years ago

Sorry, I overlooked the 3.4+ specification in setup.py. I think that is enough.

But given how good people are at postponing uncomfortable steps like migrating away from python2, I would give them some warning or reminder that you intend to end support for python2. Maybe a deprecation warning at the start of scripts and/or some note in the README.

Just my humble opinion.

Code suggestion (let me know if you would like me to create a PR with this added to all scripts):

from datetime import date
PY2END = date(2020, 1, 1)
...
def main(...):
    ... (parse args, print banner)
    if sys.version_info.major <= 2:
        if date.today() > PY2END:
            print('You are using python2 which is no longer maintained!')
        else:
            print('You are using python2 whose end-of-life is in only {} days.'
                  .format((PY2END - date.today()).days))
        print('We strongly suggest you upgrade to python3 now. See '
              'https://docs.python.org/3/howto/pyporting.html .')