aws / aws/jsii

Python pdb support?

Open
#4,535 3 comments 11 reactions 0 assignees View on GitHub
effort/medium feature-request jsii language/python management/devenv p2
Dominant language
TypeScript
Stars
2.9k
Forks
267
Avg merge
1d 25m
Merged PRs (30d)
14

Description

It would nice to be able to use built in 'pdb' Python debugger module to inspect/step through generation of template.

### Use Case

This would allow us to use native breakpoints, instead of using print-log style debugging.

### Proposed Solution

### Other

Currently, when I use pdb, it fails with following trace:

```
(.env) username@sabu:~/git/PROJ-cdk-customer$ cdk diff
> /home/username/git/PROJ-cdk-customer/PROJ_cdk_customer/customer_stack.py(77)addVPNConnections()
-> for count,customer_gateway_id in enumerate(customer_gateway_ids):
(Pdb)
Traceback (most recent call last):
File "app.py", line 29, in
customerStack(app,"customerStack-%s" % region, PROJConfig, env=core.Environment(region=region))
File "/home/username/git/PROJ-cdk-customer/.env/lib/python3.7/site-packages/jsii/_runtime.py", line 66, in __call__
inst = super().__call__(*args, **kwargs)
File "/home/username/git/PROJ-cdk-customer/PROJ_cdk_customer/customer_stack.py", line 32, in __init__
self.PROJvpc.addVPNConnections(config.shortname,config.get_resource_for(config.VPN_CUSTOMER_GATEWAY_KEY))
File "/home/username/git/PROJ-cdk-customer/PROJ_cdk_customer/customer_stack.py", line 77, in addVPNConnections
for count,customer_gateway_id in enumerate(customer_gateway_ids):
File "/home/username/git/PROJ-cdk-customer/PROJ_cdk_customer/customer_stack.py", line 77, in addVPNConnections
for count,customer_gateway_id in enumerate(customer_gateway_ids):
File "/usr/lib/python3.7/bdb.py", line 88, in trace_dispatch
return self.dispatch_line(frame)
File "/usr/lib/python3.7/bdb.py", line 113, in dispatch_line
if self.quitting: raise BdbQuit
```

I think this results from CDK trying to dump stuff to stdout and pdb expecting to handle user input from stdin.

* [ ] :wave: I may be able to implement this feature request
* [ ] :warning: This feature might incur a breaking change

---

This is a :rocket: Feature Request

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the pdb failure during cdk diff and read jsii/_runtime.py alongside the Python bdb traceback. Determine how jsii's runtime output and input handling interact with pdb, then verify that native breakpoints can be used without BdbQuit while template generation continues.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, typescript
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.