[issue44554] pdb.main is unnecessarily complicated

2021-07-19 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44554] pdb.main is unnecessarily complicated

2021-07-18 Thread miss-islington


miss-islington  added the comment:


New changeset 2c2055884420f22afb4d2045bbdab7aa1394cb63 by Jason R. Coombs in 
branch 'main':
bpo-44554: refactor pdb targets (and internal tweaks) (GH-26992)
https://github.com/python/cpython/commit/2c2055884420f22afb4d2045bbdab7aa1394cb63


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44554] pdb.main is unnecessarily complicated

2021-07-18 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

Additional problems I noticed while working on the refactor:

- There is a lot of overlap in behavior between the implementations of 
_run_script and _run_module (initializing private variables, setting 
mainpyfile, resetting the __main__ namespace).

- There are two block comments in _run_script whose behaviors apply to 
_run_module as well, but the block comments are not associated with those 
behaviors in _run_module.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44554] pdb.main is unnecessarily complicated

2021-07-02 Thread Jason R. Coombs


Change by Jason R. Coombs :


--
keywords: +patch
pull_requests: +25561
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/26992

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44554] pdb.main is unnecessarily complicated

2021-07-02 Thread Jason R. Coombs


New submission from Jason R. Coombs :

While investigating issue44461, I observed some complexities to the current 
pdb.main implementation, some of which likely contributed to the bug being 
present.

- variables are initialized to defaults 
(https://github.com/python/cpython/blob/ec8759b060eff83ff466f42c5a96d83a685016ce/Lib/pdb.py#L1677-L1678)
 and then mutated 
(https://github.com/python/cpython/blob/ec8759b060eff83ff466f42c5a96d83a685016ce/Lib/pdb.py#L1684-L1686)
 based on other variables.

- mainpyfile is conditionally mutated based on previous values of conditionally 
mutated variables 
(https://github.com/python/cpython/blob/ec8759b060eff83ff466f42c5a96d83a685016ce/Lib/pdb.py#L1696).

- There are three different blocks of code 
(https://github.com/python/cpython/blob/ec8759b060eff83ff466f42c5a96d83a685016ce/Lib/pdb.py#L1690-L1691,
 
https://github.com/python/cpython/blob/ec8759b060eff83ff466f42c5a96d83a685016ce/Lib/pdb.py#L1696-L1698,
 and 
https://github.com/python/cpython/blob/ec8759b060eff83ff466f42c5a96d83a685016ce/Lib/pdb.py#L1711)
 that are conditionally run based on run_as_module.

These factors mean that all of these lines of code are entangled in ways that 
are somewhat difficult to reason about. For example, it's unclear what states 
have been achieved by the time `pdb._run*` is constructed, or what exceptions 
may or may not be expected for these calls.

A functional or OO approach would limit the amount of mutation and entanglement 
(through encapsulation or scoping).

An OO approach would have a protocol or interface that captures the different 
behaviors required prior to and on invocation of `Pdb._run*`.

For example, the PDB "targets" (script or module) could be modeled as separate 
classes and provide symmetric interfaces with (possibly degenerate) equivalent 
operations for each use-case.

To be sure, the code that's present is adequate and in my opinion right on the 
border of benefiting from a more rigorous abstraction. The current imperative 
approach is fairly readable and mostly comprehensible. It's only because of the 
surprise behavior in the reported issue that I propose to step back and 
contemplate ways to alleviate the concerns above.

--
components: Library (Lib)
messages: 396877
nosy: iritkatriel, jaraco
priority: normal
severity: normal
status: open
title: pdb.main is unnecessarily complicated
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com