[Python] Migration help for ECU-TEST 2021.4 and Python 3.9

Issue

ECU-TEST 2021.4 is based on Python 3.9, whereas ECU-TEST 2021.3 and earlier versions shipped with Python 3.7. There are incompatible changes in Python 3.9, so unadapted code may not be executable. This also applies to user code and external Python libraries. The necessary adaptations should be implemented until the changeover to ECU-TEST 2021.4.

ECU-TEST version

2020.1

2020.2

...

2021.3

2021.4

Python version

3.7.3

3.7.3

...

3.7.3

3.9.7

Solution

Replace critical deprecated code

  1. Open the following PDF file.

  2. Navigate to the list in chapter 6.2.4. The most important adaptions (Old code <> New Code) are listed therein.

  3. Open your ECU-TEST user extensions (g. User utilities, UserPyModules, Python trace step templates, external Python libraries) with any text base editor like Notepad++ or your preferred IDE.

  4. Search for the critical deprecated code and perform the corresponding replacements.

  5. Save your changes.

Additionally, you may take a more thorough approach and collect Python deprecation warnings
during runtime of your code.

Collect Python deprecation warnings in ECU-TEST via feature flag

Python deprecation warnings are filtered out in ECU-TEST by default and are neither written in the ECU-TEST error log, out log nor in the message window. In order to display Python deprecation warnings, you need to place a feature flag in your ECU-TEST workspace. A feature flag is an option to activate code that enables a feature that is deactivated by default.

In ECU-TEST feature flags are stored in the features.xml file within the .workspace folder of your ECU-TEST Workspace.

 

Warning

It is strongly advised to use ECU-TEST 2021.3 for this procedure. In case you are running a lower
version of ECU-TEST, there will be an attempt to create the corresponding deprecation log in the program folder
where the ECU-TEST.exe executable is stored. If ECU-TEST has no permission to create and modify files here it
may cause unstable behavior.

In ECU-TEST 2021.3 the deprecation log file is created in your temp directory where ECU-TEST has the
necessary privileges.

 

If you do not use any feature flags:

  1. Download this file.

  2. Save it in the .workspace folder next to the other XML files storing your settings.

  3. Restart ECU-TEST.

  4. The message FEATURE 'ENABLE-DEPRECATION-WARNINGS' is activated! is shown within the ECU-TEST message window.

If you use feature flags:

  1. Copy the feature ENABLE-DEPRECATION-WARNINGS into your features.xml file. 

  2. Save your changes.

  3. Restart ECU-TEST.

  4. The message FEATURE 'ENABLE-DEPRECATION-WARNINGS' is activated! is shown within the ECU-TEST message window.

In your temp directory (%temp%\ECU-TEST 2021.3 by default) a log file will be created:

  • DeprecationWarning_<WorkspaceName>.log

This deprecation log will store all deprecation warnings (and only these) that are created during runtime of ECU-TEST. Thus, you can use this information to systematically get rid of all the deprecation warnings.

Example:

The following code within a called function variable of a saved package will result in a deprecation warning:

import time; time.clock()
YYYY-MM-DD hh:mm:ss: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead Found in: C:\path\to\Package.pkg

Note

The deprecation log is never cleared, enabling you to run projects, packages, configurations and generators in
multiple sessions.

Note

By this approach you may also discover ECU-TEST internal deprecation warnings that were not fixed in
ECU-TEST 2021.3 – feel free to submit these to support@tracetronic.com to help us improve ECU-TEST.

 

Further information regarding Python 3.9 migration can be found here: