Skip to content

Conversation

@albmartmart
Copy link

Why I did it

When KLISH invokes Python actioners using builtin="clish_pyobj", Python C extensions (such as charset_normalizer and the SSL module) fail to load due to missing Python C API symbols. This affects all commands using this invocation method, including MCLAG commands and any new implementations.

Fixes #151

How I did it

Modified CLI/klish/patches/klish-2.1.4/plugins/clish/call_pyobj.c to load the Python shared library with RTLD_GLOBAL before initializing Python, making Python C API symbols globally available:

void pyobj_init() {  
    void *python_lib = dlopen("libpython3.11.so.1.0", RTLD_NOW | RTLD_GLOBAL);  
    if (!python_lib) {  
        fprintf(stderr, "Failed to load Python library: %s\n", dlerror());  
    }  
    Py_Initialize();  
}

I also fixed the wrong Python2 print statements from CLI/actioner/sonic_cli_mclag.py.

How to verify it

  1. Build SONiC VS image with the fix
  2. Login to the virtual switch
  3. Run sonic-cli
  4. Execute configure terminal
  5. Execute no mclag domain 432 (command should work without "Internal error")

@mssonicbld
Copy link

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@albmartmart
Copy link
Author

Hi @gitsabari , I saw you’ve contributed to similar issues before.
If you have a chance, could you please take a quick look and let me know if the proposed approach makes sense, or if there’s a preferred way to handle it within the project?
Thanks in advance for your time!

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.

[Bug] KLISH Python C Extension Loading Failure Affecting builtin="clish_pyobj" Commands

2 participants