From 1155b13d19470ee31b04e10d2ba702bf7f9ca98b Mon Sep 17 00:00:00 2001 From: orbisai0security Date: Fri, 24 Apr 2026 17:19:38 +0000 Subject: [PATCH] fix: V-001 security vulnerability Automated security fix generated by Orbis Security AI --- .../pse_postprocess/pse/__init__.py | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/ppocr/postprocess/pse_postprocess/pse/__init__.py b/ppocr/postprocess/pse_postprocess/pse/__init__.py index 60288025e59..3a067c48056 100644 --- a/ppocr/postprocess/pse_postprocess/pse/__init__.py +++ b/ppocr/postprocess/pse_postprocess/pse/__init__.py @@ -13,21 +13,23 @@ # limitations under the License. import sys import os -import subprocess - -python_path = sys.executable +import runpy ori_path = os.getcwd() os.chdir("ppocr/postprocess/pse_postprocess/pse") -if ( - subprocess.call("{} setup.py build_ext --inplace".format(python_path), shell=True) - != 0 -): - raise RuntimeError( - "Cannot compile pse: {}, if your system is windows, you need to install all the default components of `desktop development using C++` in visual studio 2019+".format( - os.path.dirname(os.path.realpath(__file__)) +_saved_argv = sys.argv +try: + sys.argv = ["setup.py", "build_ext", "--inplace"] + runpy.run_path("setup.py", run_name="__main__") +except SystemExit as e: + if e.code != 0: + raise RuntimeError( + "Cannot compile pse: {}, if your system is windows, you need to install all the default components of `desktop development using C++` in visual studio 2019+".format( + os.path.dirname(os.path.realpath(__file__)) + ) ) - ) -os.chdir(ori_path) +finally: + sys.argv = _saved_argv + os.chdir(ori_path) from .pse import pse