[Mesa-dev] [PATCH mesa 2/3] egl: fix python lib deprecation warning
Eric Engestrom
eric.engestrom at intel.com
Wed Nov 7 17:12:43 UTC 2018
On Wednesday, 2018-11-07 09:51:12 -0700, Kyle Brenneman wrote:
> On 11/07/2018 06:20 AM, Eric Engestrom wrote:
> > DeprecationWarning: the imp module is deprecated in favour of importlib
> >
> > importlib is available since python 2.7 and 3.1, and we already require
> > 2.7 and 3.4 so we can simply use the new lib.
> >
> > Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
> > ---
> > src/egl/generate/gen_egl_dispatch.py | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/egl/generate/gen_egl_dispatch.py b/src/egl/generate/gen_egl_dispatch.py
> > index eeb3f3f9a5a2051b9585..0c4d2956eff28911336c 100644
> > --- a/src/egl/generate/gen_egl_dispatch.py
> > +++ b/src/egl/generate/gen_egl_dispatch.py
> > @@ -34,7 +34,7 @@
> > import argparse
> > import collections
> > -import imp
> > +import importlib.machinery
> > import sys
> > import textwrap
> > @@ -51,7 +51,7 @@ def main():
> > # The function list is a Python module, but it's specified on the command
> > # line.
> > - eglFunctionList = imp.load_source("eglFunctionList", args.func_list_file)
> > + eglFunctionList = importlib.machinery.SourceFileLoader("eglFunctionList", args.func_list_file).load_module()
> > xmlFunctions = genCommon.getFunctions(args.xml_files)
> > xmlByName = dict((f.name, f) for f in xmlFunctions)
> I think importlib.machinery.SourceFileLoader is only available starting with
> Python 3.3, so the script would break if you tried to run it with Python 2.
>
> For what it's worth, though, loading the eglFunctionList module dynamically
> like that was originally intended just to make it easier for a vendor
> library to use the gen_egl_dispatch.py script from libglvnd, but with its
> own function list. In Mesa's case, just a simple "import eglFunctionList"
> would probably work just as well.
Good point, I didn't think about it hard enough. I'll send a v2 with
that tomorrow.
What do you think about patch 3? Am I butchering something we should
be keeping around?
More information about the mesa-dev
mailing list