Python 3 Warning Mode

In 3ds Max 2020.2 Update and later, 3ds Max and 3ds Max Batch support the Py3k warnings mode, where many common constructs and APIs executed in a Python 2.x script that will not run in Python 3.x generate warnings. This mode allows you to prepare your scripts to run under Python 3.x, which will be supported in a future version of 3ds Max. Note that this mode is not exhaustive, and may not generate warnings for all incompatibilities.

When warning mode is enabled, warnings are printed to the MAXScript Listner window or the Max Batch console, and are logged to the Max.log file. For example:

>>> print `1+2`
<console>:1: SyntaxWarning: backquote not supported in 3.x; use repr()

And a corresponding line is written to the max.log file:

2019/06/10 11:30:17 ERR: [31336] [02296] <console>:1: SyntaxWarning: backquote not supported in 3.x; use repr()

Note: The previous example actually generates three warnings. A single construct might generate more than one warning if the scrutinizer uses multiple code paths to analyze it.

Warnings are generated regardless of how the script is executed, whether from the Listener, from the MAXScript Editor Evaluate All command, from the Scripting > Run Script menu command, or even when executed from MAXScript using Python.Execute() or Python.ExecuteFile().

Turning On the Warning Mode

The warning mode is enabled in one of two ways:

Note: The python3Warning command line option overrides the ADSK_3DSMAX_PTYHON3_WARNING setting, if they have conflicting settings.

Migrating Your Code

There are many good resources for those who want to migrate their 2.x Python code to 3.x. Here are a few: