-1

This is not a duplicate of a related question When/where should I check for the minimum Python version?.

My problem is that and I'm not sure if it is a good idea in the first place.

My program starts with (X does not matter now):

if sys.version_info < (3, X):
    raise RuntimeError("Python ver. 3.X or higher is required")

and I cannot recall why I put that test there.

Well, it gives a clear message instead of some obscure error, but that's all.

The program is being developed and keeping the X up-to-date is not easy. I don't want to go into details in order to avoid opinion-based discussion about setting X.

I'd like to reduce the question to simple yes or no for version check. Are there any existing guidelines?

VPfB
  • 14,927
  • 6
  • 41
  • 75
  • 1
    "Errors should never pass silently." - `import this`. – double_j Jun 23 '17 at 17:42
  • You already have the message in place, and it doesn't hurt to have it there. (Like you said, it actually makes errors potentially clearer.) So why waste time thinking about whether to remove the check or not? – 0x5453 Jun 23 '17 at 17:44
  • What happens if you remove the check and execute your script with a version before _Python3.X_? You could then try with a previous version of that one and so on (til the point it no longer works). – CristiFati Jun 23 '17 at 17:45

2 Answers2

3

Remove the check entirely. This info belongs in the package metadata, so it will be caught at install time - not at runtime.

You're clearly not writing a cross-compat library here, so the only .py file that should contain any information about supported Python versions is the setup.py file.

(Note: even if you were writing a cross-compat library, best practice is usually to isolate any version-specific detail into a separate compat.py module)

wim
  • 338,267
  • 99
  • 616
  • 750
0

A few options:

  • Can you check commit messages around the time the line was added and see if you complained about something in them? Maybe then do a diff and see what changed before and after the line was added. It could guide you to the specific part and tell you why you insisted on X.

  • You can also head to the "What's New in Python 3.X" section of the documentation https://docs.python.org/3/whatsnew/3.X.html) and hunt down what changed that made you want Python 3.X and not Python 3.(X-1) (a diff of sorts on Python itself). Whatever the reason you had to raise an exception instead of issuing a warning, it has to be there in the change log.

Jugurtha Hadjar
  • 441
  • 3
  • 7