Skip to content

Conversation

@justinjhendrick
Copy link

@justinjhendrick justinjhendrick commented Mar 26, 2025

Goal: Make it easier to build this project from source

What I changed:

  • ran 2to3
  • Manually fixed some str vs bytes differences
  • Replace ordereddict.py with collections.OrderedDict
  • Use raw strings in regex
  • Use socket.error.args to check for EAGAIN
  • Replace string.maketrans with str.maketrans
  • Replace inspect.getargspec with inspect.getfullargspec
    • seems equivalent because we're only using 0th index of return value which didn't change
  • Remove indexing on OSError. Just call str on it
  • Update configure to accept python3.8 and newer

Warnings with this change:

  • This drops support for python2
    • Is that a problem?
    • I chose this because it seems easier than supporting both simultaneously
  • I can't be certain if I broke something
    • Because I don't understand most of this code
    • Because my testing doesn't cover all the code (see below)

How I tested this:

  • Build and run with python3.12.3 on Ubuntu 24.04 (in Windows 10 WSL)
  • Look through errors that mypy reported for anything that seems related to the migration:
    • This command was helpful python -m mypy --check-untyped-defs --exclude scripts/analyze-migration.py --exclude tests/image-fuzzer/qcow2/ . --disable-error-code='import-untyped' --disable-error-code='var-annotated'
    • There are a lot of false positives from mypy though, because there are no type hints

@justinjhendrick justinjhendrick changed the title Draft: Migrate to Python3 Migrate to Python3 Mar 26, 2025
@justinjhendrick
Copy link
Author

justinjhendrick commented Mar 29, 2025

Eventually, we probably want to merge with a newer version of upstream qemu (https://gitlab.com/qemu-project/qemu) but that may be a large undertaking and this will improve the development workflow in the short/medium term.

SteveUcho pushed a commit to SteveUcho/pebble-qemu that referenced this pull request May 7, 2025
Address a memory leak bug in the usages of timer_del().

The issue arises from the incorrect use of the ambiguous timer API
timer_del(), which does not free the timer object. The LeakSanitizer
report this issue during fuzzing. The correct API timer_free() freed
the timer object instead.

=================================================================
==2586273==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x55f2afd89879 in calloc /llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:75:3
    pebble-dev#1 0x7f443b93ac50 in g_malloc0 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x5ec50)
    pebble-dev#2 0x55f2b053962e in timer_new include/qemu/timer.h:542:12
    pebble-dev#3 0x55f2b0514771 in timer_new_us include/qemu/timer.h:582:12
    pebble-dev#4 0x55f2b0514288 in lsi_scsi_realize hw/scsi/lsi53c895a.c:2350:24
    pebble-dev#5 0x55f2b0452d26 in pci_qdev_realize hw/pci/pci.c:2174:9

Signed-off-by: Zheng Huang <hz1624917200@outlook.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <73cd69f9-ff9b-4cd4-b8aa-265f9d6067b9@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
@Hexxeh
Copy link

Hexxeh commented Aug 27, 2025

Oh, one thing I missed, the commit messages should probably use the conventional commits style like the previous PRs and firmware repo: https://www.conventionalcommits.org/en/v1.0.0/

BREAKING CHANGE: drop support for Python 2

Signed-off-by: Justin Hendrick <justinjhendrick@gmail.com>
@justinjhendrick
Copy link
Author

@Hexxeh, I've rewritten the commit message

@justinjhendrick justinjhendrick changed the title Migrate to Python3 Migrate to Python 3 Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants