Strange behavior of REPL

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
User avatar
jcf
Posts: 60
Joined: Wed Mar 03, 2021 11:14 am

Strange behavior of REPL

Post by jcf » Sat Apr 16, 2022 10:01 am

Yesterday when I wanted to demonstrate to some friends how easy it is to work with a Pico, I noticed something strange.

In normal Python on the PC, I was used to this:

Code: Select all

>>> 3+5
8
The Pico did this:

Code: Select all

MicroPython v1.18 on 2022-01-17; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>> 3+5
0x11
I suppose the "0x11" is something like an address?

Is this behavior wanted or is it a bug?
I don't remember having noticed it in the past.

By the way,

Code: Select all

>>> print(3+5)
8
gives the right result.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Strange behavior of REPL

Post by pythoncoder » Sat Apr 16, 2022 11:04 am

Not here it doesn't:

Code: Select all

MicroPython v1.18-143-g40f424516 on 2022-03-27; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>> 3+5
8
FWIW it would undoubtedly be a bug - but I can't explain what you're seeing.
Peter Hinch
Index to my micropython libraries.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Strange behavior of REPL

Post by Roberthh » Sat Apr 16, 2022 11:20 am

I get proper results as well.

Code: Select all

>>> 3+5
8
>>> 
MicroPython v1.18-355-g9ab66b50c on 2022-04-16; Raspberry Pi Pico with RP2040
Type "help()" for more information.
Edit: using the generic 1.18 version as well:

Code: Select all

>>> 3+5
8
>>> 
MicroPython v1.18 on 2022-01-17; Raspberry Pi Pico with RP2040
Type "help()" for more information.

User avatar
jcf
Posts: 60
Joined: Wed Mar 03, 2021 11:14 am

Re: Strange behavior of REPL

Post by jcf » Sun Apr 17, 2022 7:31 am

I tested it again, this time by using GtkTerm as terminal, and I got the right result:

Code: Select all

MicroPython v1.18 on 2022-01-17; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>> 3+5
8
So it must be a bug in Thonny!

Shards
Posts: 39
Joined: Fri Jun 25, 2021 5:14 pm
Location: Milton Keynes, UK

Re: Strange behavior of REPL

Post by Shards » Mon Apr 18, 2022 6:57 am

Or possibly the version of Thonny you are using? Works right for me using Thonny 3.2.7 on Linux Mint 20.1

User avatar
jcf
Posts: 60
Joined: Wed Mar 03, 2021 11:14 am

Re: Strange behavior of REPL

Post by jcf » Mon Apr 18, 2022 8:20 am

The problem occured in version 3.3.14 under Linux Mint

KJM
Posts: 158
Joined: Sun Nov 18, 2018 10:53 pm
Location: Sydney AU

Re: Strange behavior of REPL

Post by KJM » Mon Apr 18, 2022 12:25 pm

Maybe let the Thonny folks know, I've found them super helpful.

User avatar
jcf
Posts: 60
Joined: Wed Mar 03, 2021 11:14 am

Re: Strange behavior of REPL

Post by jcf » Mon Apr 18, 2022 3:48 pm

I did so, and I got a really fast answer (super!):
Did you have the Heap pane (View => Heap) opened? In this case Thonny was in "heap mode", which is meant for explaining mutable objects (see https://youtu.be/nwIgxrXP-X4?t=247 for explanation)
And, yes, that was the reason.

Post Reply