prserv/serv: Avoid exception with newer versions of Python
The following exception was received when doing devtool modify ...:
Exception: ModuleNotFoundError: No module named '_sysconfigdata'
This was previously partially solved in OE-Core, in commit 4b26eaf7 (prservice.py: fix do_package with newer Python in Ubuntu 20.04). However, that only solved the problem for some cases where prserv was imported. This should solve if for all of them.
Signed-off-by Peter Kjellerstedt <[email protected]>
--- bitbake/lib/prserv/serv.py | 6 ++++++ 1 file changed, 6 insertions(+)
bitbake/lib/prserv/serv.py +6 -0
@@ -2,6 +2,12 @@ # SPDX-License-Identifier: GPL-2.0-only # +# Make sure _PYTHON_SYSCONFIGDATA_NAME is not set in the environment, which may +# happen for recipes that, e.g., inherit python3native, which sets it. Otherwise +# importing from xmlrpc.server fails with "No module named '_sysconfigdata'" +if '_PYTHON_SYSCONFIGDATA_NAME' in os.environ: + del os.environ['_PYTHON_SYSCONFIGDATA_NAME'] + import os,sys,logging import signal, time from xmlrpc.server import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler