@@ -1465,7 +1465,7 @@ def discard_changes(self) -> None:
14651465
14661466 def rpc_send_ly (
14671467 self , rpc_input : libyang .DNode , timeout_ms : int = 0
1468- ) -> libyang .DNode :
1468+ ) -> Optional [ libyang .DNode ] :
14691469 """
14701470 Send an RPC/action and wait for the result.
14711471
@@ -1480,7 +1480,7 @@ def rpc_send_ly(
14801480
14811481 :returns:
14821482 The RPC/action output tree. Allocated dynamically and must be freed by the
1483- caller.
1483+ caller. If the RPC/action did not return any output, None is returned.
14841484 :raises SysrepoError:
14851485 If the RPC/action callback failed.
14861486 """
@@ -1491,7 +1491,7 @@ def rpc_send_ly(
14911491 sr_data_p = ffi .new ("sr_data_t **" )
14921492 check_call (lib .sr_rpc_send_tree , self .cdata , in_dnode , timeout_ms , sr_data_p )
14931493 if not sr_data_p [0 ]:
1494- raise SysrepoInternalError ( "sr_rpc_send_tree returned NULL" )
1494+ return None
14951495
14961496 ctx = self .acquire_context ()
14971497 dnode = libyang .DNode .new (ctx , sr_data_p [0 ].tree )
@@ -1515,7 +1515,7 @@ def rpc_send(
15151515 include_implicit_defaults : bool = False ,
15161516 trim_default_values : bool = False ,
15171517 keep_empty_containers : bool = False ,
1518- ) -> Dict :
1518+ ) -> Optional [ Dict ] :
15191519 """
15201520 Same as rpc_send_ly() but takes a python dictionary and a YANG module name as
15211521 input arguments.
@@ -1539,7 +1539,8 @@ def rpc_send(
15391539 Include empty (non-presence) containers.
15401540
15411541 :returns:
1542- A python dictionary with the RPC/action output tree.
1542+ A python dictionary with the RPC/action output tree or None if the RPC/action
1543+ did not return any output.
15431544 """
15441545 rpc = {}
15451546 libyang .xpath_set (rpc , xpath , input_dict )
@@ -1553,6 +1554,9 @@ def rpc_send(
15531554 finally :
15541555 in_dnode .free ()
15551556
1557+ if out_dnode is None :
1558+ return None
1559+
15561560 try :
15571561 out_dict = out_dnode .print_dict (
15581562 strip_prefixes = strip_prefixes ,
0 commit comments