← index #15776Issue #15230
Off-topic · high · value 1.230
QUERY · ISSUE

RP2 build, doc strings, help()

openby thestumbleropened 2024-09-03updated 2024-11-22
bug

Port, board and/or hardware

rp2 pico

MicroPython version

MicroPython v1.24.0-preview.278.g5e692d046.dirty on 2024-09-03; RP2040

I have set MICROPY_ENABLE_DOC_STRING (1) in mpconfigboard.h

When building this way, I can clearly see, and print, __doc__ for each class. But the help() function doesn't return the docstring like it does in Python on the desktop.Also, there is only a __doc__ on a class -- on functions a doc string is not created regardless of the setting in mpconfigboard.h. Is this the expected behavior? Is this maybe unique to the RP2 port? I seem to remember this working on a STM32F4 board.

Reproduction

class Ocean:
  '''This is the Ocean Class.'''
  def __init__(self):
    pass
  def wave(self):
    '''Prints a wave.'''
    print('a wave')


Expected behaviour

Expected help(Ocean) or help(o) to show the doc string. Instead it shows what looks like dir(Ocean)

Expected help(o.wave) to show the doc string for the wave() function. Instead there is no doc string.

Observed behaviour

You can see the doc object on the class, but not on the function.
help() doesn't show the usual help output

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

If boot.py doesn't exit then rp2 port will never initialise USB (soft-bricked)

closedby TRadigkopened 2024-06-08updated 2024-11-19
bugport-rp2

Port, board and/or hardware

Raspberry Pico

MicroPython version

MicroPython v1.23.0 on 2024-06-02; Raspberry Pi Pico with RP2040

Reproduction

I took my program code and stripped it down to a working repro. There are more lines that could be deleted but help with visualization. The content is saved to boot.py. There is no other file saved on the microcontroller.
With any version prior 1.23 this will yield a serial device in device manager, whenever the device is connected to the computer. With version 1.23 it will not and can only recovered by flashing a firmware version prior 1.23:

import _thread
import asyncio  # type: ignore
from time import sleep
import gc
import machine

synchronousLoopAlive: bool = True
anyLoopAlive: bool = True
led = machine.Pin(25, machine.Pin.OUT)


async def yieldingBackgroundTaskOne():
    while anyLoopAlive:
        print("One")
        led.value(not led.value())

        await asyncio.sleep_ms(1000)


def synchronousTask():
    while synchronousLoopAlive:
        sleep(2)


if __name__ == "__main__":
    try:
        sleep(3)
        loop = asyncio.get_event_loop()
        gc.collect()

        programThread = _thread.start_new_thread(synchronousTask, ())
        print("program thread started")
        taskOne = loop.create_task(yieldingBackgroundTaskOne())
        print("task One started")

        loop.run_forever()
    except KeyboardInterrupt:
        synchronousLoopAlive = False
        anyLoopAlive = False
        loop.stop()
        print("INTERRUPTED - STOPPING EVERYTHING")
    except Exception as e:
        print(f"error occurred: {e}")

Expected behaviour

Expected a serial device in device manager as in all versions prior 1.23.

Observed behaviour

No serial device in device manager with micropython 1.23, but with any version prior 1.23.

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied