How to make sure Python 2.7.10 does not violate my Python 2.7.6 code?

To simplify my work, I want to upgrade from Python 2.7.6 to Python 2.7.9 / 2.7.10.

I need to justify that my Python 2.7.10 will not break my software that works with Python 2.7.6

I followed the steps described in porting python 2 to python 3

  • Increase my test coverage from 0 to 40%
  • run pylint (no critical error)
  • Learn the differences between Python 2.7.10 and 2.7.6 <I read the release notes.

I cannot be sure that my code will not break 100%, but how can I be sure?

For example, should I search for all Core and Builtins errors installed between 2.7.6 and 2.7.10 And search in my code if we use these methods?

Is there a better strategy?

100% code coverage is a good solution, but can get more than 50% coverage + 100% code using modified methods between 2.7.6 and 2.7.10. p>

+6
source share
3 answers

This is a very minor Python update that will almost certainly not break anything, even without the above steps (switching Python 2 to Python 3 is another matter entirely).

As for the proof of this, well, without any statistical checks and reading the release notes using, since all he tells you is that it is almost certainly backward compatible (this is the initial assumption).

A possible approach would be to reproduce your production environment using Python 2.7.10 in a virtual machine (valgrind, etc. may help there) and check if everything works as expected. Do not run it in any way to be 100% sure.

Increasing coverage is a good idea. By itself, even though the full coverage performed using Python 2.7.6 does not tell you whether it will work with Python 2.7.10 or not.

+1
source

My answer applies not only to Python, but to software development in general.

First of all, as already mentioned, Python 2.7.10 is a β€œsimple” fix for fixing bugs β€” this means that all regression tests pass and that lagging incompatible changes are not taken into account. It also ensures that the signature of the function does not change, so your code is likely to work. Due to the high coverage of the Python source code, it can also be said that even if fixing the errors could lead to an error, it was covered by regression tests, so either the error was new or was not covered by regression tests (the first does not mean the second).

In addition, with 100% coverage, it is technically not always possible - 90-95% - this is usually the way to go. And if that is not enough, you can try different scripts in the local environment, as suggested by rth.

However, consider importing imported libraries / modules and see if they all support Python 2.7.10. If not, this does not mean that your project will not work, but it may happen that if you use some low-level C libraries, they may break - so be especially careful.

In general, I suggest you go through the changes and through the imported libraries. Adding coverage is always good - not just to upgrade to a new version, so I join other users saying that you definitely need to increase coverage.

+1
source

As stated in the dev-cycle presentation:

To clarify the terminology, Python uses the major.minor.micro nomenclature to produce finished products. So, for the final version of Python 3.1.2, this is major version 3, minor version 1, and micro version 2.

  • new major versions are exceptional; they appear only when strongly incompatible changes are considered necessary, and they are planned very long in advance;
  • minor new versions are feature releases; they are released approximately every 18 months, starting from the current development branch;
  • new micro versions are bug fixes; they are released approximately every 6 months, although if necessary they may appear more often; They are prepared in service branches.

This means that upgrading from a micro version to another should not (theoretically) break anything. This is the same for minor versions, which should only add features that are backward compatible.

Given how widely used python is, you can be sure that many tests have been done to ensure that this is respected.
Nevertheless, there is no guarantee, but the whole point of the micro-versions is the correction of errors, not the appearance of new errors.

+1
source

All Articles