cpython icon indicating copy to clipboard operation
cpython copied to clipboard

gh-142570: Check the file type before skipping the source first line

Open nybblista opened this issue 1 month ago • 3 comments

pymain_run_file_obj: Check the file type before skipping the source first line.

  • Issue: gh-142570

nybblista avatar Dec 14 '25 11:12 nybblista

@picnixz

nybblista avatar Dec 18 '25 15:12 nybblista

@ZeroIntensity

nybblista avatar Dec 31 '25 14:12 nybblista

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

bedevere-app[bot] avatar Jan 02 '26 21:01 bedevere-app[bot]

I have made the requested changes; please review again.

nybblista avatar Jan 11 '26 18:01 nybblista

Thanks for making the requested changes!

@ZeroIntensity: please review the changes made to this pull request.

bedevere-app[bot] avatar Jan 11 '26 18:01 bedevere-app[bot]

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be poked with soft cushions!

bedevere-app[bot] avatar Jan 11 '26 19:01 bedevere-app[bot]

Anyway, I'm almost certain there's already a test that stresses the "correct" case. I don't think we need to add another one with this PR.

If that's the case, then I agree with you.

However, so what we should do with:

  1. The current order of operations in the pymain_run_file_obj which I believe it does not make sense.
  2. The interception of the directory arguments by pymain_get_importer will make dead code inside the pymain_run_file_obj. For this reason, even if we reorder the operations inside pymain_run_file_obj (as in this PR), still, keeping the check-for-directory code does not make sense if we believe that the pymain_run_file_obj will be called only when the filename is a script file.

nybblista avatar Jan 12 '26 14:01 nybblista