Skip to content

Commit

Permalink
Fix bug for debug level in case of SyntaxError (use script value inst…
Browse files Browse the repository at this point in the history
…ead of page value if both are set)
  • Loading branch information
PierreQuentel committed Nov 5, 2024
1 parent 8a891fe commit d34a9e9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
9 changes: 4 additions & 5 deletions www/src/brython.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()}}
Expand Down
2 changes: 1 addition & 1 deletion www/src/pegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 4 additions & 3 deletions www/src/py2js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions www/src/version_info.js
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit d34a9e9

Please sign in to comment.