Skip to content

fix(make): Ensure Python 3 compatibility#16

Merged
nerdCopter merged 1 commit intoemuflight:masterfrom
nerdCopter:20251004_update_for_python
Oct 5, 2025
Merged

fix(make): Ensure Python 3 compatibility#16
nerdCopter merged 1 commit intoemuflight:masterfrom
nerdCopter:20251004_update_for_python

Conversation

@nerdCopter
Copy link
Copy Markdown
Member

@nerdCopter nerdCopter commented Oct 4, 2025

The build script make.py was using ctypes to monkey-patch the built-in str type for path separator conversion. This approach is not compatible with Python 3 and caused the script to fail.

This commit refactors the script by removing the ctypes-based "magic code" and replacing it with a simple fix_path helper function. All calls to the old .path property have been updated to use this new, more robust function.

fixes:

$ ./make.py -T=F3
Traceback (most recent call last):
  File "/home/ndronet/SYNC/nerdCopter-GIT/imu-f_nerdRepo/./make.py", line 64, in <module>
    get_dict(str)['path'] = get_path_method
    ^^^^^^^^^^^^^
  File "/home/ndronet/SYNC/nerdCopter-GIT/imu-f_nerdRepo/./make.py", line 56, in get_dict
    return _get_dict(object).contents.value
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: PyObject is NULL

The build script `make.py` was using `ctypes` to monkey-patch the built-in `str` type for path separator conversion. This approach is not compatible with Python 3 and caused the script to fail.

This commit refactors the script by removing the `ctypes`-based "magic code" and replacing it with a simple `fix_path` helper function. All calls to the old `.path` property have been updated to use this new, more robust function.
@nerdCopter
Copy link
Copy Markdown
Member Author

builds, flashes, works (unsoldered)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes Python 3 compatibility issues in the make.py build script by removing unsafe ctypes-based monkey-patching of the built-in str type and replacing it with a simple helper function for path separator conversion.

  • Removed complex ctypes code that was causing crashes in Python 3
  • Added a simple fix_path() helper function for cross-platform path handling
  • Updated all references from .path property calls to fix_path() function calls

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@nerdCopter
Copy link
Copy Markdown
Member Author

@Quick-Flash , please approve.

@nerdCopter nerdCopter merged commit e1e0333 into emuflight:master Oct 5, 2025
2 checks passed
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.

3 participants