From d34a9e96c942ebfa2f2e3610dc3aad8dbf94dfed Mon Sep 17 00:00:00 2001 From: PierreQuentel Date: Tue, 5 Nov 2024 08:17:22 +0100 Subject: [PATCH] Fix bug for debug level in case of SyntaxError (use script value instead of page value if both are set) --- www/src/brython.js | 9 ++++----- www/src/pegen.js | 2 +- www/src/py2js.js | 7 ++++--- www/src/version_info.js | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/www/src/brython.js b/www/src/brython.js index 6a24acb2e..92f88180a 100644 --- a/www/src/brython.js +++ b/www/src/brython.js @@ -209,8 +209,8 @@ $B.unicode_bidi_whitespace=[9,10,11,12,13,28,29,30,31,32,133,5760,8192,8193,8194 ; __BRYTHON__.implementation=[3,13,1,'dev',0] __BRYTHON__.version_info=[3,13,0,'final',0] -__BRYTHON__.compiled_date="2024-11-04 22:08:45.912843" -__BRYTHON__.timestamp=1730754525912 +__BRYTHON__.compiled_date="2024-11-05 08:16:06.546261" +__BRYTHON__.timestamp=1730790966546 __BRYTHON__.builtin_module_names=["_ajax","_ast","_base64","_binascii","_io_classes","_json","_jsre","_locale","_multiprocessing","_posixsubprocess","_profile","_random","_sre","_sre_utils","_string","_strptime","_svg","_symtable","_tokenize","_webcomponent","_webworker","_zlib_utils","_zlib_utils1","_zlib_utils_kozh","array","builtins","dis","encoding_cp932","encoding_cp932_v2","hashlib","html_parser","marshal","math","modulefinder","posix","pyexpat","python_re","python_re_new","unicodedata","xml_helpers","xml_parser","xml_parser_backup"] ; @@ -945,7 +945,7 @@ if($B.$options.hasOwnProperty(option)){ return $B.$options[option]}else if(brython_options.hasOwnProperty(option)){ return brython_options[option]}else{return default_option[option]}} $B.get_option=function(option,err){var filename=$B.script_filename -if(err && err.$frame_obj){filename=$B.get_frame_at(0,err.$frame_obj).__file__}else{filename=$B.get_filename()} +if(err && err.filename){filename=err.filename}else if(err && err.$frame_obj){filename=$B.get_frame_at(0,err.$frame_obj).__file__}else{filename=$B.get_filename()} return $B.get_option_from_filename(option,filename)} $B.get_option_from_filename=function(option,filename){if(filename===undefined ||! $B.scripts[filename]){return $B.get_page_option(option)} var value=$B.scripts[filename].getAttribute(option) @@ -991,8 +991,7 @@ _b_.__debug__=$B.get_option('debug')> 0 var root,js try{root=$B.py2js({src:src,filename},name,name) js=root.to_js() -if($B.get_option_from_filename('debug',filename)> 1){console.log($B.format_indent(js,0))}}catch(err){console.log('err',err) -return $B.handle_error($B.exception(err))} +if($B.get_option_from_filename('debug',filename)> 1){console.log($B.format_indent(js,0))}}catch(err){return $B.handle_error($B.exception(err))} var _script={__doc__:get_docstring(root._ast),js:js,__name__:name,__file__:url,script_element:script} $B.tasks.push(["execute",_script]) if(run_loop){$B.loop()}} diff --git a/www/src/pegen.js b/www/src/pegen.js index 725284305..452276c8b 100644 --- a/www/src/pegen.js +++ b/www/src/pegen.js @@ -661,7 +661,7 @@ $B._PyPegen.number_token = function(p){ } var c = parsenumber(num_raw); - + if (c == NULL) { p.error_indicator = 1; var tstate = _PyThreadState_GET(); diff --git a/www/src/py2js.js b/www/src/py2js.js index 5f293387c..706eeb4d3 100644 --- a/www/src/py2js.js +++ b/www/src/py2js.js @@ -331,7 +331,7 @@ $B.py2js = function(src, module, locals_id, parent_scope){ // normalize line ends to \n src = src.replace(/\r\n/g, '\n'). - replace(/\r/g, '\n') + replace(/\r/g, '\n') var locals_is_module = Array.isArray(locals_id) if(locals_is_module){ locals_id = locals_id[0] @@ -693,7 +693,9 @@ $B.get_page_option = function(option){ $B.get_option = function(option, err){ var filename = $B.script_filename - if(err && err.$frame_obj){ + if(err && err.filename){ + filename = err.filename + }else if(err && err.$frame_obj){ filename = $B.get_frame_at(0, err.$frame_obj).__file__ }else{ filename = $B.get_filename() @@ -808,7 +810,6 @@ $B.run_script = function(script, src, name, url, run_loop){ console.log($B.format_indent(js, 0)) } }catch(err){ - console.log('err', err) return $B.handle_error($B.exception(err)) // in loaders.js } var _script = { diff --git a/www/src/version_info.js b/www/src/version_info.js index a3407232e..53df3e7b3 100644 --- a/www/src/version_info.js +++ b/www/src/version_info.js @@ -1,7 +1,7 @@ __BRYTHON__.implementation = [3, 13, 1, 'dev', 0] __BRYTHON__.version_info = [3, 13, 0, 'final', 0] -__BRYTHON__.compiled_date = "2024-11-04 22:08:45.912843" -__BRYTHON__.timestamp = 1730754525912 +__BRYTHON__.compiled_date = "2024-11-05 08:16:06.546261" +__BRYTHON__.timestamp = 1730790966546 __BRYTHON__.builtin_module_names = ["_ajax", "_ast", "_base64",