Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SAI adapter exception due to POE PSE attribute conflicting with v…
…ariables in sai_adapter.py. (#2011) After the recent POE PSE API update, the SAI adapter python script will fail on launch with the exception below: byte-compiling /dash/dash-pipeline/SAI/saithrift/../rpc/usr/local/lib/python3.10/site-packages/sai_thrift/sai_adapter.py to sai_adapter.cpython-310.pyc File "/dash/dash-pipeline/SAI/saithrift/../rpc/usr/local/lib/python3.10/site-packages/sai_thrift/sai_adapter.py", line 37000 global status ^^^^^^^^^^^^^ SyntaxError: name 'status' is parameter and global The reason is because the POE PSE API has a attribute with name STATUS: /** * @brief POE PSE attributes */ typedef enum _sai_poe_pse_attr_t { ... /** * @brief Status of the PSE * * @type sai_poe_pse_status_t * @flags READ_ONLY */ SAI_POE_PSE_ATTR_STATUS, ... } sai_poe_pse_attr_t; This causes the status parameter being generated in the SAI thrift adapter, and conflicting with the variable global status: Fix Since it is not ideal to change the API name, as it might break any code rely on it. This commit updates the template for generating the adapter code with 2 changes: Rename the status global variable into sai_status. Add a fallback __getattr__ function (called after no attribute is found), which ensures any existing code that gets the status variable will not break, such as adapter.status. Signed-off-by: r12f <r12f.code@gmail.com>
- Loading branch information