CaringCaribou / caringcaribou

A friendly car security exploration tool for the CAN bus
GNU General Public License v3.0
751 stars 197 forks source link

replace time.clock() with time.process_time() #63

Closed sigttou closed 3 years ago

sigttou commented 3 years ago

fix compatibility with python 3.8 (time.clock() deprecated since 3.3)

kasperkarlsson commented 3 years ago

Hello @sigttou and thank you for sending a PR with this fix!

While it is most true that time.clock() needs to be replaced to work with newer versions of Python, there is however a problem with backwards compatibility (since Caring Caribou also supports Python versions down to 2.7).

Would you be able to address this as well? One simple way would be to do something like this at the top of the file:

import time
# Fix for backward compatibility with Python versions older than 3.3,
# where time.process_time is not available
try:
    time.process_time
except AttributeError:
    time.process_time = time.clock

Doing this and keeping the change in your commit to use time.process_time would result in adding support for newer versions without breaking it for older ones.

If you fix this, I would be happy to accept your PR straight away!

sigttou commented 3 years ago

Yeah sure, thanks for pointing this out, didn't think of python 2.x no more 👍

kasperkarlsson commented 3 years ago

Excellent! Thanks a lot 😃

kasperkarlsson commented 3 years ago

@sigttou By the way, would you like to be listed under the Contributors section?

https://github.com/CaringCaribou/caringcaribou#contributors

If so, just let me know which name/handle you prefer and I'll put it in!

sigttou commented 3 years ago

Hi, "sigttou' is just fine, thank you :)

kasperkarlsson commented 3 years ago

Great! Thank you for contributing 😃👍

https://github.com/CaringCaribou/caringcaribou/commit/dab7678ca19c5d0abff7bb1e0c6b1b8b83fa55a3