Re: Fix python3 deprecation warning

Karl Berry <[email protected]>
Newsgroups gmane.comp.sysutils.automake.patches
Message-ID <[email protected]>
Hi Gabriel - back on your patch from last July (sorry):

    https://lists.gnu.org/archive/html/automake-patches/2019-07/msg00002.html

    replace the imp functions with the new ones from importlib.
    ...
    -import sys, os, py_compile, imp
    +import sys, os, py_compile, importlib

I understand the problem, but unfortunately the new code is not
compatible with Python 2. I don't know the best way to handle that. Help?

With the patch, the tests, e.g., py-compile-basedir, fail with the
not-unexpected:

  + ./py-compile --basedir foo __init__.py sub/__init__.py
  Byte-compiling python modules...
  __init__.pyTraceback (most recent call last):
    File "<string>", line 15, in <module>
  AttributeError: 'module' object has no attribute 'implementation'

I know Python 2 itself is being eradicated, but still, automake cannot
simply abandon it. 

About all I can imagine is to change the above line to something like:
  import sys, os, py_compile, $import_library
and check the version number of $PYTHON in the script before and set
$import_library accordingly. That is not especially pretty. Is there
a way to do it within Python that would be cleaner and work with both
versions?

I also don't see the deprecation warning, but I only have Python 3.6.8
at the moment, so I suppose it came in with Python 3.7. --thanks, karl.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.