Skip to content

Commit

Permalink
Don't set position if a call spans over several lines. Fix regression…
Browse files Browse the repository at this point in the history
… in error reporting introduced by replacement of frames_stack by frame_obj
  • Loading branch information
PierreQuentel committed Oct 23, 2023
1 parent e331652 commit 805a58e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
12 changes: 8 additions & 4 deletions www/src/ast_to_js.js
Original file line number Diff line number Diff line change
Expand Up @@ -1220,10 +1220,14 @@ $B.ast.Break.prototype.to_js = function(scopes){

$B.ast.Call.prototype.to_js = function(scopes){
var func = $B.js_from_ast(this.func, scopes),
position = encode_position(this.col_offset, this.col_offset,
this.end_col_offset),
js = `$B.$call(${func}, ${position})`,
args = make_args.bind(this)(scopes)
js = `$B.$call(${func}`
if(this.end_lineno == this.lineno){
var position = encode_position(this.col_offset, this.col_offset,
this.end_col_offset)
js += `, ${position}`
}
js += ')'
var args = make_args.bind(this)(scopes)

return js + (args.has_starred ? `.apply(null, ${args.js})` :
`(${args.js})`)
Expand Down
15 changes: 9 additions & 6 deletions www/src/brython.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ $B.stdlib_module_names=Object.keys($B.stdlib)})(__BRYTHON__)
;
__BRYTHON__.implementation=[3,12,0,'dev',0]
__BRYTHON__.version_info=[3,12,0,'final',0]
__BRYTHON__.compiled_date="2023-10-23 13:01:17.755848"
__BRYTHON__.timestamp=1698058877755
__BRYTHON__.compiled_date="2023-10-23 17:57:43.238719"
__BRYTHON__.timestamp=1698076663238
__BRYTHON__.builtin_module_names=["_aio","_ajax","_ast","_base64","_binascii","_cmath","_io_classes","_json","_jsre","_locale","_multiprocessing","_posixsubprocess","_profile","_random","_sre","_sre1","_sre_utils","_string","_strptime","_svg","_symtable","_tokenize","_webcomponent","_webworker","_zlib_utils","array","builtins","dis","encoding_cp932","hashlib","html_parser","marshal","math","module1","modulefinder","posix","python_re","python_re1","python_re2","unicodedata"]
;
;(function($B){var _b_=$B.builtins
Expand Down Expand Up @@ -5151,8 +5151,7 @@ err.$frame_obj=frame_obj
err.$linenums=linenums}}
$B.handle_error(err)}
loop()}else{
try{func.apply(null,args)}catch(err){console.log('err',err)
$B.handle_error(err)}}}
try{func.apply(null,args)}catch(err){$B.handle_error(err)}}}
$B.tasks=[]
$B.has_indexedDB=self.indexedDB !==undefined
function required_stdlib_imports(imports,start){
Expand Down Expand Up @@ -8008,7 +8007,7 @@ $B.get_exc=function(){var frame=$B.frame_obj.frame
return frame[1].$current_exception}
$B.set_exception_offsets=function(exc,position){
exc.$positions=exc.$positions ||{}
exc.$positions[$B.count_frames()-1]=position
exc.$positions[$B.frame_obj.count-1]=position
return exc}
$B.$raise=function(arg,cause){
var active_exc=$B.get_exc()
Expand Down Expand Up @@ -15634,7 +15633,11 @@ scope.ast instanceof $B.ast.While){js+=`no_break_${scope.id} = false\n`
break}}
js+=`break`
return js}
$B.ast.Call.prototype.to_js=function(scopes){var func=$B.js_from_ast(this.func,scopes),position=encode_position(this.col_offset,this.col_offset,this.end_col_offset),js=`$B.$call(${func}, ${position})`,args=make_args.bind(this)(scopes)
$B.ast.Call.prototype.to_js=function(scopes){var func=$B.js_from_ast(this.func,scopes),js=`$B.$call(${func}`
if(this.end_lineno==this.lineno){var position=encode_position(this.col_offset,this.col_offset,this.end_col_offset)
js+=`, ${position}`}
js+=')'
var args=make_args.bind(this)(scopes)
return js+(args.has_starred ? `.apply(null, ${args.js})` :
`(${args.js})`)}
function make_args(scopes){var js='',named_args=[],named_kwargs=[],starred_kwargs=[],has_starred=false
Expand Down
2 changes: 1 addition & 1 deletion www/src/py_exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $B.get_exc = function(){
$B.set_exception_offsets = function(exc, position){
// Used for PEP 657
exc.$positions = exc.$positions || {}
exc.$positions[$B.count_frames() - 1] = position
exc.$positions[$B.frame_obj.count - 1] = position
return exc
}

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, 12, 0, 'dev', 0]
__BRYTHON__.version_info = [3, 12, 0, 'final', 0]
__BRYTHON__.compiled_date = "2023-10-23 13:01:17.755848"
__BRYTHON__.timestamp = 1698058877755
__BRYTHON__.compiled_date = "2023-10-23 17:57:43.238719"
__BRYTHON__.timestamp = 1698076663238
__BRYTHON__.builtin_module_names = ["_aio",
"_ajax",
"_ast",
Expand Down

0 comments on commit 805a58e

Please sign in to comment.