Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cannot add extra arguments when inheriting FGFDMExec #611

Closed
bcoconni opened this issue Apr 9, 2022 · 1 comment
Closed

Cannot add extra arguments when inheriting FGFDMExec #611

bcoconni opened this issue Apr 9, 2022 · 1 comment
Assignees

Comments

@bcoconni
Copy link
Member

bcoconni commented Apr 9, 2022

As I was investigating @sinizu's request in discussion #516, I discovered that the commit 31ea0ff has never been cherry picked to the branch release/v1.1. So it is currently not possible to add arguments to a class constructor that inherits from jsbsim.FGFMExec.

For instance, the code fails for v1.1.11 but succeeds for the master branch

import jsbsim

class myFDMExec(jsbsim.FGFDMExec):
    def __init__(self, root_dir, pm_root, extra):
        self._extra = extra
        super().__init__()
@bcoconni bcoconni added the bug label Apr 9, 2022
@bcoconni bcoconni self-assigned this Apr 9, 2022
@bcoconni bcoconni added the Python label Apr 9, 2022
bcoconni added a commit that referenced this issue Apr 9, 2022
Extra arguments cannot be added to the constructor of classes that inherit from `FGFDMExec`.
bcoconni added a commit that referenced this issue Apr 9, 2022
As specified by cython docs [1], the arguments `*args`, and `**kwargs` have been added to all cinit() methods to allow subclassing with extra arguments.

[1] https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html#initialisation-methods-cinit-and-init
bcoconni added a commit that referenced this issue Apr 9, 2022
Extra arguments cannot be added to the constructor of classes that inherit from `FGFDMExec`.
@bcoconni
Copy link
Member Author

bcoconni commented Apr 9, 2022

The bug has been fixed by the commit e6e31f8.
Also added regression tests:

@bcoconni bcoconni closed this as completed Apr 9, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant