Skip to content

Commit

Permalink
Fixes #683 : exception when calling JavaScript function with "None" a…
Browse files Browse the repository at this point in the history
…s an argument
  • Loading branch information
Pierre Quentel committed Sep 23, 2017
1 parent f4048ac commit e305359
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions www/src/brython.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ $B.regexIdentifier=/^(?:[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C
__BRYTHON__.implementation=[3,3,4,'dev',0]
__BRYTHON__.__MAGIC__="3.3.4"
__BRYTHON__.version_info=[3,3,0,'alpha',0]
__BRYTHON__.compiled_date="2017-09-21 09:42:48.339270"
__BRYTHON__.compiled_date="2017-09-23 09:27:25.434778"
__BRYTHON__.builtin_module_names=["posix","sys","errno","time","_ajax","_base64","_jsre","_multiprocessing","_posixsubprocess","_profile","_svg","_sys","builtins","dis","hashlib","json","long_int","math","modulefinder","random","_abcoll","_codecs","_collections","_csv","_functools","_imp","_io","_random","_socket","_sre","_string","_struct","_sysconfigdata","_testcapi","_thread","_warnings","_weakref"]

;(function($B){var js,$pos,res,$op
Expand Down Expand Up @@ -6975,7 +6975,7 @@ if(self.js_func && self.js_func[attr]!==undefined){js_attr=self.js_func[attr]}
if(js_attr !==undefined){if(typeof js_attr=='function'){
var res=function(){
var args=[]
for(var i=0,_len_i=arguments.length;i < _len_i;i++){if(arguments[i].$nat!=undefined){
for(var i=0,_len_i=arguments.length;i < _len_i;i++){if(arguments[i]!==null && arguments[i].$nat!=undefined){
throw TypeError("A Javascript function can't "+
"take keyword arguments")}else{args.push(pyobj2jsobj(arguments[i]))}}
if(attr==='replace' && self.js===location){location.replace(args[0])
Expand Down Expand Up @@ -10596,7 +10596,7 @@ _b_.frozenset=frozenset})(__BRYTHON__)
;(function($B){eval($B.InjectBuiltins())
var $ObjectDict=_b_.object.$dict
var JSObject=$B.JSObject
var _window=self;
var _window=window
$B.events=_b_.dict()
function $getMouseOffset(target,ev){ev=ev ||_window.event;
var docPos=$getPosition(target);
Expand Down
6 changes: 3 additions & 3 deletions www/src/brython_dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ $B.regexIdentifier=/^(?:[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C
__BRYTHON__.implementation=[3,3,4,'dev',0]
__BRYTHON__.__MAGIC__="3.3.4"
__BRYTHON__.version_info=[3,3,0,'alpha',0]
__BRYTHON__.compiled_date="2017-09-21 09:42:48.339270"
__BRYTHON__.compiled_date="2017-09-23 09:27:25.434778"
__BRYTHON__.builtin_module_names=["posix","sys","errno","time","_ajax","_base64","_jsre","_multiprocessing","_posixsubprocess","_profile","_svg","_sys","builtins","dis","hashlib","json","long_int","math","modulefinder","random","_abcoll","_codecs","_collections","_csv","_functools","_imp","_io","_random","_socket","_sre","_string","_struct","_sysconfigdata","_testcapi","_thread","_warnings","_weakref"]

;(function($B){var js,$pos,res,$op
Expand Down Expand Up @@ -6975,7 +6975,7 @@ if(self.js_func && self.js_func[attr]!==undefined){js_attr=self.js_func[attr]}
if(js_attr !==undefined){if(typeof js_attr=='function'){
var res=function(){
var args=[]
for(var i=0,_len_i=arguments.length;i < _len_i;i++){if(arguments[i].$nat!=undefined){
for(var i=0,_len_i=arguments.length;i < _len_i;i++){if(arguments[i]!==null && arguments[i].$nat!=undefined){
throw TypeError("A Javascript function can't "+
"take keyword arguments")}else{args.push(pyobj2jsobj(arguments[i]))}}
if(attr==='replace' && self.js===location){location.replace(args[0])
Expand Down Expand Up @@ -10596,7 +10596,7 @@ _b_.frozenset=frozenset})(__BRYTHON__)
;(function($B){eval($B.InjectBuiltins())
var $ObjectDict=_b_.object.$dict
var JSObject=$B.JSObject
var _window=self;
var _window=window
$B.events=_b_.dict()
function $getMouseOffset(target,ev){ev=ev ||_window.event;
var docPos=$getPosition(target);
Expand Down
5 changes: 2 additions & 3 deletions www/src/js_objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ $JSObjectDict.__getattribute__ = function(self,attr){
//if(attr=='setValue'){console.log('run function')}
var args = []
for(var i=0, _len_i = arguments.length; i < _len_i;i++){
if(arguments[i].$nat!=undefined){
if(arguments[i] !== null && arguments[i].$nat!=undefined){
//
// Passing keyword arguments to a Javascript function
// raises a TypeError : since we don't know the
Expand Down Expand Up @@ -241,8 +241,7 @@ $JSObjectDict.__getattribute__ = function(self,attr){
if (this !== null && this !== undefined && this !== _window) {
new_this = this
}
//if(attr=='setValue'){console.log('get result')}


var result = js_attr.apply(new_this, args)

// NOTE: fix for situations when wrapped function is constructor (thus it does not return and value is lost)
Expand Down
2 changes: 1 addition & 1 deletion www/src/py_dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ eval($B.InjectBuiltins())

var $ObjectDict = _b_.object.$dict
var JSObject = $B.JSObject
var _window = self;
var _window = window //self;

// Maps $brython_id of DOM elements to events
$B.events = _b_.dict()
Expand Down
2 changes: 1 addition & 1 deletion www/src/version_info.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__BRYTHON__.implementation = [3, 3, 4, 'dev', 0]
__BRYTHON__.__MAGIC__ = "3.3.4"
__BRYTHON__.version_info = [3, 3, 0, 'alpha', 0]
__BRYTHON__.compiled_date = "2017-09-21 09:42:48.339270"
__BRYTHON__.compiled_date = "2017-09-23 09:27:25.434778"
__BRYTHON__.builtin_module_names = ["posix","sys", "errno", "time","_ajax",
"_base64",
"_jsre",
Expand Down

0 comments on commit e305359

Please sign in to comment.