Support over zoom

23 views
Skip to first unread message

Eilon

unread,
May 6, 2025, 12:16:46 AMMay 6
to brython
Hi, I have few problems, I think that a short zoom meeting could help me a lot.
Is there an option for getting that kind of support ? I'm willing to pay for the time.
Thanks

Denis Migdal

unread,
May 6, 2025, 2:50:24 AMMay 6
to brython
Hi,


I don't mind being present, but I'm not sure to be able to answer all questions.

What exactly causes you issues ?


Cordially,

Eilon

unread,
May 6, 2025, 5:25:27 AMMay 6
to brython
Thank you Denis for your response ❤️,
I have some questions that I think are suitable for the creator of Brython, regarding of future plans -
like adding a unique id for each error message. Now, I need to translate each error message to different languages, 
If there was a unique id It was solve this problem.
Do you have any suggestions?
Thanks, 
Eilon


Denis Migdal

unread,
May 6, 2025, 6:10:08 AMMay 6
to brython
A very simple solution : use regexes to parse the error message and then translate it :
```
const reg = new Regex(/^%([\w+]) format: a real number is required, not ([\w]+)$/);
if ( res = reg.exec(msg) )
    return `Error: ${res[0]} foo ${res[1]}`;

// do other regex for other error messages.
```

We could also modify Brython.

Maybe it could be possible to replace :

```
if(! $B.$isinstance(s, [_b_.int, _b_.float]) ){
        var type = flags.conversion_type
        throw _b_.TypeError.$factory(`%${type} format: a real number ` +
            `is required, not ${$B.class_name(s)}`)
    }
```

By :
```
function raw(...args) { return args; }

_b_.assertError( $B.$isinstance(s, [_b_.int, _b_.float]), _b_.TypeError, raw`%${flags.conversion_type} format: a real number is required, not ${$B.class_name(s)}` )
```

Then you could override `assertError`to build your own error message.

Maybe a message/error factory could be useful:
```
_b_.errorsMsg = {
     formatRealRequired : (format, s) => _b_.TypeError.$factory(`%${format} format: a real number is required, not ${$B.class_name(s)}`)
}

_b_.assertError( $B.$isinstance(s, [_b_.int, _b_.float]), _b_.errorsMsg.formatRealRequired(flags.conversion_type, s) );
```

But that would require lot of changes to the Brython code.

Denis Migdal

unread,
May 6, 2025, 6:34:01 AMMay 6
to brython
You could also use the excepthook : https://docs.python.org/2/library/sys.html#sys.excepthook

Eilon

unread,
May 6, 2025, 7:28:04 AMMay 6
to brython
Thank you Denis for the suggestions! - I will look into it !

Eilon

unread,
May 7, 2025, 4:08:52 AMMay 7
to brython
Hi Denis, I just posted a new query about errors. I'll much  appreciate  if you could take a look 
Reply all
Reply to author
Forward
0 new messages