From 50b1f1fb4435e7d36d5ef12403d8ec23aab93fd9 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Thu, 28 Dec 2023 15:55:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=9E=20DEBUG=20=E7=8E=AF=E5=A2=83=E4=B8=8D?= =?UTF-8?q?=E8=A6=81=E6=98=BE=E7=A4=BA=E8=B0=83=E8=AF=95=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conv.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/conv.php b/conv.php index 670a5c50..7573db6b 100644 --- a/conv.php +++ b/conv.php @@ -3,6 +3,7 @@ if ($argc < 2) { die("Usage: php conv.php [python-file]\n"); } +define('DEBUG', getenv('PY2PHP_DEBUG')); $py_script = __DIR__ . '/dump.py'; $result = shell_exec('python ' . $py_script . ' ' . $argv[1]); $json = json_decode($result); @@ -17,9 +18,11 @@ function debug($v) { global $translator; if ($translator->mode == 'cli') { - echo 'Error: Unsupported Python Syntax, Line: ' . $v->lineno . PHP_EOL; - debug_print_backtrace(); - var_dump($v); + echo 'Error: Unsupported Python Syntax, Line: ' . $v->lineno . ', Type: ' . $v->_type . PHP_EOL; + if (DEBUG) { + debug_print_backtrace(); + var_dump($v); + } } else { header('Content-Type: application/json'); echo json_encode($v, JSON_PRETTY_PRINT);