GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — bpo-44554: refactor pdb targets (and internal tweaks) by jaraco · Pull Request #26992 · python/cpython Conversation
|
| commands = [optarg for opt, optarg in opts if opt in ['-c', '--command']] | ||
|
|
||
| if not run_as_module: | ||
| mainpyfile = os.path.realpath(mainpyfile) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This line changes the meaning of mainpyfile mid-function. It's because of this behavior that ScriptTarget contains an 'orig' property (to keep both representations), even though the "real path" form is the preferred one except during error checking.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This changes the behavior of pdb, right? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
This PR extracts the refactoring only, but not the fix for bpo-44461, as discussed in iritkatriel#16.
One place this refactoring could go awry is if there were other callers of Please do have a look at this approach as it focuses on the refactoring and ignores the concerns for now in fixing the reported issue. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I do not believe this changes the behavior except for a couple subtle differences. I'll point those out in the diff. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
A refactor changes the code to improve its structure without changing its behavior. I don't think you can call this a refactor.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
When you're done making the requested changes, leave the comment: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| commands = [] | ||
| run_as_module = False | ||
| for opt, optarg in opts: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Previously, the opts would be iterated over just once. In this new code, they are iterated over three times. Any performance degradation is negligible and outweighed by the value of disentangling the concerns.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| target.check() | ||
|
|
||
| sys.argv[:] = args # Hide "pdb.py" and pdb options from argument list |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In the previous implementation, assignment of sys.argv[:] would happen before the sys.path change. In the new code, the sys.path change happens during the ScriptTarget.check. I contend these two operations are independent and can happen in any order.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This PR doesn't really have anything to do with the reported issue. It should be a new BPO. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return res | ||
|
|
||
| def check(self): | ||
| if not os.path.exists(self): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Previously, the existence check was done on mainpyfile before it was mutated to a "real path". Now the existence check is the real path. If compatibility is needed, this line could be changed to:
| if not os.path.exists(self): | |
| if not os.path.exists(self.orig): |
But in my opinion, the existence check on either form is equivalent, and the form presented is more readable and distracts less from the primary intention for self.orig (the error message).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It's not equivalent for anonymous pipes created by process substitution (see GH-142315).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Perhaps I'm using the term too loosely. I believe the changes do not change the behavior or interfaces for the intended use-cases. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Respectfully, I disagree. The whole point of this refactor is to enable an earlier check for a runpy module target, symmetric to the syntax check on a script target, a technique which has been shown to fix the issue (thanks to your analysis and test). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I think you are using it too loosely. A refactor improves the code without changing its behavior. As I said, pdb has quite a few different use cases. I don't know it well enough to tell which changes are minor and which will break someone's debugger. Any behavior change needs to be associated with a bpo and news item that states clearly what the change is, not sneaked into a refactor. I'm also not sure about the motivation here. We have a fix for the reported bug. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I've updated the blurb and PR title to reflect that it's more than a refactor. But I do genuinely expect this change to result in no significant behavior change. Can you point to a behavior change that you think is more than a refactor?
The motivation comes from my observation here that when the target is a script, there's a separate check for its existence (and similarly later a separate trap for bad syntax) that doesn't go through the Pdb interactive module. In my opinion, passing an invalid module to As I analyzed the issue, following your analysis and initial patch, I felt uneasy with adding the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I believe that by first applying this refactor, then applying the test and fix in iritkatriel#16, you get a superior fix, avoiding adding a |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Since it handles bad modules differently (we agree on that right?) it's already more than a refactor. That may be a minor change, it might be a good change, I don't know. I need to spend some time reviewing it. I've moved on to work on something else between last week and now. I don't have time at the moment to convince myself that your change is safe. I'll have a look when I have time, unless someone else will before me. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Sorry this wasn't clear. In this change, But as I think about it, perhaps the concerns this change addresses could be enumerated in its own bug.
No problem. I understand. Thanks for taking the time to review as much as you have already and for keeping me apprised of your schedule so I'm not left feeling abandoned. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for making the requested changes! @iritkatriel: please review the changes made to this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…n properties of the Target object.
There was an error while loading. Please reload this page.
|
In fe8aea5, I've pushed an additional refactor that consolidates This change has the additional benefit of restoring the association of the comments with their function. Prior to this change, the two block comments in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This version is indeed clearer. Can spec() and details() be _spec() and _details()?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…Union in the module.
Done in c91ba80. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jaraco: Status check is done, and it's a success ❌ . |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jaraco: Status check is done, and it's a success ✅ . |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, I can't merge this PR. Reason: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jaraco: Status check is done, and it's a success ✅ . |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* origin/main: (1146 commits) bpo-42064: Finalise establishing sqlite3 global state (pythonGH-27155) bpo-44678: Separate error message for discontinuous padding in binascii.a2b_base64 strict mode (pythonGH-27249) correct spelling (pythonGH-27076) bpo-44524: Add missed __name__ and __qualname__ to typing module objects (python#27237) bpo-27513: email.utils.getaddresses() now handles Header objects (python#13797) Clean up comma usage in Doc/library/functions.rst (python#27083) bpo-42238: Fix small rst issue in NEWS.d/. (python#27238) bpo-41972: Tweak fastsearch.h string search algorithms (pythonGH-27091) bpo-44340: Add support for building with clang full/thin lto (pythonGH-27231) bpo-44661: Update property_descr_set to use vectorcall if possible. (pythonGH-27206) bpo-44645: Check for interrupts on any potentially backwards edge (pythonGH-27216) bpo-41546: make pprint (like print) not write to stdout when it is None (pythonGH-26810) bpo-44554: refactor pdb targets (and internal tweaks) (pythonGH-26992) bpo-43086: Add handling for out-of-spec data in a2b_base64 (pythonGH-24402) bpo-44561: Update hyperlinks in Doc/distributing/index.rst (python#27032) bpo-42355: symtable.get_namespace() now checks whether there are multiple or any namespaces found (pythonGH-23278) bpo-44654: Do not export the union type related symbols (pythonGH-27223) bpo-44633: Fix parameter substitution of the union type with wrong types. (pythonGH-27218) bpo-44654: Refactor and clean up the union type implementation (pythonGH-27196) bpo-20291: Fix MSVC warnings in getargs.c (pythonGH-27211) ...
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.