cfv icon indicating copy to clipboard operation
cfv copied to clipboard

DeprecationWarning: the imp module is deprecated in favour of importlib

Open sbraz opened this issue 3 years ago • 1 comments

HI, running tests, I noticed this warning:

cfv/test/cfvtest.py:26: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
    import imp

I didn't file a PR as I'm not exactly sure what https://github.com/cfv-project/cfv/blob/08ee2679488d9424549345021cf36538bbea9a35/test/cfvtest.py#L205 is used for.

sbraz avatar Nov 01 '22 15:11 sbraz

From what I can tell it is used by the old test harness. It can run all tests inside one Python process or spawn a new Python processes for each test. Whenever cfv needs to be called it uses this wrapper script: https://github.com/cfv-project/cfv/blob/779d30f3aa0c6f4cb77b694823db64a0a89200af/test/cfv It modifies the sys.path variable, so that it executes the cfv version from the directory instead of running a system-wide installation: https://github.com/cfv-project/cfv/blob/779d30f3aa0c6f4cb77b694823db64a0a89200af/test/cfv#L6 According to the comment above the line you mentioned, imp.load_source is only used to ensue that sys.path is modified: https://github.com/cfv-project/cfv/blob/779d30f3aa0c6f4cb77b694823db64a0a89200af/test/cfvtest.py#L204 I am not really sure myself if this is still needed or was only required in older Python versions. At least the comment was added in 2006: https://github.com/cfv-project/cfv/commit/4cf1b20a44b17aa913c544852827703ab37ab41a

lxp avatar Nov 01 '22 15:11 lxp

Fixed by #53

lxp avatar May 18 '24 09:05 lxp