brython-dev / brython

Brython (Browser Python) is an implementation of Python 3 running in the browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

py2js isn't called anymore ?

denis-migdal opened this issue · comments

Hi,

Context:

I'm currently working on a script enabling to use my webcomponent library (LISS) with Brython (I use it for my student practical work).

I found a simple solution to easily and properly integrate it : override __BRYTHON__.jsobj2pyobj and __BRYTHON__.pyobj2jsobj to convert a Python class to a JS class in such a way the integration should not cause issue.

The issue:

__BRYTHON__.pyobj2jsobj doesn't seem to be called anymore when giving a Py object to a JS function :

from browser import window

class X:
     pass

x = X()

window.console.log(x)
const jsobj2pyobj = __BRYTHON__.jsobj2pyobj;
__BRYTHON__.jsobj2pyobj = function(obj){

	console.log("js2py", obj);

	return jsobj2pyobj(obj);
}


const pyobj2jsobj = __BRYTHON__.pyobj2jsobj;
__BRYTHON__.pyobj2jsobj = function(obj){

	console.log("py2js", obj);

	return pyobj2jsobj(obj);
}

In the current dev version, __BRYTHON__.pyobj2jsobj isn't called, but in older versions, it was called.
I'll try to check which commit causes the issue.

Cordially,

This change of behavior has been introduced in commit 0a5c58a

Found another way to proceed.