Skip to content

Commit

Permalink
fix: TypeError when trying to use bin-scripts in Python (#2720)
Browse files Browse the repository at this point in the history
### Problem
Bin script on Python is failing with error `The "path" argument must be of type string. Received undefined`

### Solution
- Changed parameter name `pkgname` on `assembly` in `InvokeScriptRequest`
- Returned response from `invokeBinScript` (used for printing output)

### Testing
Running bin script with these change and make sure that bin scripts are running.
  • Loading branch information
kozlove-aws committed Mar 22, 2021
1 parent 891f457 commit acdf1a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
InvokeRequest,
InvokeResponse,
InvokeScriptRequest,
InvokeScriptResponse,
KernelResponse,
LoadRequest,
ObjRef,
Expand Down Expand Up @@ -254,13 +255,13 @@ def load(self, name: str, version: str, tarball: str) -> None:

def invokeBinScript(
self, pkgname: str, script: str, args: Optional[List[Any]] = None
) -> None:
) -> InvokeScriptResponse:
if args is None:
args = []

self.provider.invokeBinScript(
return self.provider.invokeBinScript(
InvokeScriptRequest(
pkgname=pkgname,
assembly=pkgname,
script=script,
args=_make_reference_for_native(self, args),
)
Expand Down
4 changes: 2 additions & 2 deletions packages/@jsii/python-runtime/src/jsii/_kernel/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class LoadResponse:
@attr.s(auto_attribs=True, frozen=True, slots=True)
class InvokeScriptRequest:

pkgname: str
assembly: str
script: str
args: List[Any] = attr.Factory(list)

Expand All @@ -55,7 +55,7 @@ class InvokeScriptResponse:
status: int
stdout: str
stderr: str
output: List[str]
signal: str


@attr.s(auto_attribs=True, frozen=True, slots=True)
Expand Down

0 comments on commit acdf1a9

Please sign in to comment.