Canvas code from Brython 3.0 to Brython 3.2

44 views
Skip to first unread message

dan d.

unread,
Jul 29, 2015, 6:54:12 AM7/29/15
to brython
Hello,

I have not been active for a while and saw  version 3.2 of Brython was out. So I wanted to test my last simple HTML5 canvas brython code with version 3.2 of Brython.
And of course it dies :)  hehehe

I kept the exact same HTML file and .py code file that I used successfully with version 3.0 of Brython.

Test page:   http://webswap.free.fr/brythonrocks/v2/simple2.html
Code page:  http://webswap.free.fr/brythonrocks/v2/simple2.py

I'm straching my head :)

I get this error stack:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help http://xhr.spec.whatwg.org/ brython.js:3901
Error:  brython.js line 5785 > eval:131
Error:
Stack trace:
_b_.SyntaxError@http://webswap.free.fr/brythonrocks/v2/brython.js line 5785 > eval:131:396
$B.$SyntaxError@http://webswap.free.fr/brythonrocks/v2/brython.js:4610:46
$_SyntaxError@http://webswap.free.fr/brythonrocks/v2/brython.js:95:47
$transition@http://webswap.free.fr/brythonrocks/v2/brython.js:2613:96
$transition@http://webswap.free.fr/brythonrocks/v2/brython.js:2845:1
$transition@http://webswap.free.fr/brythonrocks/v2/brython.js:3095:1
$tokenize@http://webswap.free.fr/brythonrocks/v2/brython.js:3705:1
$B.py2js@http://webswap.free.fr/brythonrocks/v2/brython.js:3785:5
brython@http://webswap.free.fr/brythonrocks/v2/brython.js:3921:10
onload@http://webswap.free.fr/brythonrocks/v2/simple2.html:1:1
 brython.js:3934
"__name__ : " "SyntaxError" brython.js:3935
"$js_exc : " undefined brython.js:3935
"args : " Array [ "non-keyword arg after keyword arg", Array[4] ] brython.js:3935
"$message : " "non-keyword arg after keyword arg" brython.js:3935
"__class__ : " Object { __class__: Object, __name__: "SyntaxError", __bases__: Array[1], __module__: "builtins", __mro__: Array[4], $factory: _b_.SyntaxError() } brython.js:3935
"$py_error : " true brython.js:3935
"$stack : " Array [ Array[2] ] brython.js:3935
"$line_info : " "39,__main__" brython.js:3935
"Traceback (most recent call last):
  module __main__ line 39
            drawRotateImage(imgBall, self.pos[0], self.pos[1], rotationAngle = 0, 90, 90, 90, 90)
SyntaxError: non-keyword arg after keyword arg,__main__,39,73,drawRotateImage(imgBall, self.pos[0], self.pos[1], rotationAngle = 0, 90, 90, 90, 90)"

dan d.

unread,
Jul 29, 2015, 7:09:18 AM7/29/15
to brython, dandelso...@gmail.com
This was tested on Firefox 31.8 under Debian Linux and on Firefox 34 on Windows 8. Same Error stack in both cases.
It also dies under Chrome.

Dan

Billy Earney

unread,
Jul 29, 2015, 7:39:01 AM7/29/15
to bry...@googlegroups.com, dandelso...@gmail.com
Hi Dan,

Should the rotationAngle argument be a tuple or list?

so

  drawRotateImage(imgBall, self.pos[0], self.pos[1], rotationAngle = 0, 90, 90, 90, 90)

should be:

  drawRotateImage(imgBall, self.pos[0], self.pos[1], rotationAngle = (0, 90, 90, 90, 90))

Billy
     

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/2ee150af-3f90-4f63-9f3d-725b22abe8ac%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

dan d.

unread,
Jul 29, 2015, 8:53:07 AM7/29/15
to brython, billy....@gmail.com
Hey Billy

Actually no, its not a list or a tuple. Its an integer.
Turns out in brython 3.0 the syntax with  "parameter name = value" in the parameter list of a function, did not raise an error. But in version 3.2, it raises an error. At least, I think this is the problem. Is this a bug in brython 3.2 ?

So to fix the code, I changed it to:
drawRotateImage(imgBall, self.pos[0], self.pos[1], 0, 90, 90, 90, 90)

Before I had :

drawRotateImage(imgBall, self.pos[0], self.pos[1], rotationAngle = 0, 90, 90, 90, 90)

The function signature is:
drawRotateImage(image, posX, posY, rotationAngle, imgSizeX, imgSizeY, displaySizeX, displaySizeY)

Now the page loads and the demo works.
http://webswap.free.fr/brythonrocks/v2/simple2.html

Cheers,
Dan

Joao S. O. Bueno

unread,
Jul 29, 2015, 9:03:16 AM7/29/15
to bry...@googlegroups.com, billy....@gmail.com
On 29 July 2015 at 09:53, dan d. <dandelso...@gmail.com> wrote:
> Hey Billy
>
> Actually no, its not a list or a tuple. Its an integer.
> Turns out in brython 3.0 the syntax with "parameter name = value" in the
> parameter list of a function, did not raise an error. But in version 3.2, it
> raises an error. At least, I think this is the problem. Is this a bug in
> brython 3.2 ?

Parameter_name=value is not a bug in Brython nor in Python - which
Brython mirrors.
Now, youcan pass anonymous parameters after named parameters - that is
a syntax error
in Python, and if it passed in brython 3.0 it was a bug there. -
You passa nonymous parameters, in the order they are defined - after
tyou naem a parameter, you have to name
all other parameters that come after it.



>
> So to fix the code, I changed it to:
> drawRotateImage(imgBall, self.pos[0], self.pos[1], 0, 90, 90, 90, 90)
>
> Before I had :
> drawRotateImage(imgBall, self.pos[0], self.pos[1], rotationAngle = 0, 90,
> 90, 90, 90)
>
> The function signature is:
> drawRotateImage(image, posX, posY, rotationAngle, imgSizeX, imgSizeY,
> displaySizeX, displaySizeY)
>
> Now the page loads and the demo works.
> http://webswap.free.fr/brythonrocks/v2/simple2.html
>
> Cheers,
> Dan
>
> --
> You received this message because you are subscribed to the Google Groups
> "brython" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to brython+u...@googlegroups.com.
> To post to this group, send email to bry...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/brython/73e6f043-e47a-4326-b088-cefae20465c6%40googlegroups.com.

dan d.

unread,
Aug 1, 2015, 4:58:41 PM8/1/15
to brython
Hey Joao,

Thanks for the feedback. Sorry for my python code mistake in the function parameter list...

Cheers
Dan

Billy Earney

unread,
Aug 1, 2015, 8:50:10 PM8/1/15
to bry...@googlegroups.com

No worries!

> --
> You received this message because you are subscribed to the Google Groups "brython" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
> To post to this group, send email to bry...@googlegroups.com.

> To view this discussion on the web visit https://groups.google.com/d/msgid/brython/f8967d9a-2608-4c68-b66c-92875834cb13%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages