FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-108494: Argument clinic: Improve the `parse_file()` API by AlexWaygood · Pull Request #108575 · python/cpython · GitHub

Repository navigation

gh-108494: Argument clinic: Improve the parse_file() API - #108575

Merged
AlexWaygood merged 6 commits into
python:mainfrom
AlexWaygood:improve-parse-file
Aug 28, 2023
Merged

AlexWaygood merged 6 commits into
python:mainfrom
AlexWaygood:improve-parse-file

Conversation

AlexWaygood commented Aug 28, 2023 •
edited
Loading

Copy link
Copy Markdown
Member
  • Get rid of the ns argument to parse_file(); restore the verify argument that was removed in 1dd9510.
  • Add a limited_capi argument to parse_file(). Make the limited_capi argument to both Clinic.__init__ and parse_file required, so that callers always have to be explicit about whether the limited C API is desired or not. This means that there is a "single source of truth" about what the default is, rather than this being duplicated between the global constant and the logic in the create_cli() function.
  • Get rid of MockClinic from the test file, which was added in 1dd9510: just use our existing _make_clinic() helper function instead.

With this PR, we would need to make only these changes if we wanted to change it tomorrow so that the limited C API is the default for AC-generated code (plus a few fixes to some tests that currently depend on being able to use our internal C API):

diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py
index efc6a922c5..f4f8b2dd20 100644
--- a/Lib/test/test_clinic.py
+++ b/Lib/test/test_clinic.py
@@ -20,7 +20,7 @@
     import clinic
     from clinic import DSLParser

-DEFAULT_LIMITED_C_API = False
+DEFAULT_LIMITED_C_API = True


 def _make_clinic(*, filename='clinic_tests'):
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 2a4b6ff3b7..1a82ff7e57 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -6096,8 +6096,8 @@ def create_cli() -> argparse.ArgumentParser:
     cmdline.add_argument("--exclude", type=str, action="append",
                          help=("a file to exclude in --make mode; "
                                "can be given multiple times"))
-    cmdline.add_argument("--limited", dest="limited_capi", action='store_true',
-                         help="use the Limited C API")
+    cmdline.add_argument("--no-limited", dest="limited_capi", action='store_false',
+                         help="Don't use the Limited C API")
     cmdline.add_argument("filename", metavar="FILE", type=str, nargs="*",
                          help="the list of files to process")
     return cmdline

Closes #108504

vstinner and others added 5 commits August 26, 2023 02:34
Revert my change adding 'ns' parameter, add back 'verify' parameter,
and add also 'limited_capi' parameter.
Revert my change adding 'ns' parameter, add back 'verify' parameter,
and add also 'limited_capi' parameter.

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM, whatever works :-) I'm not going to nitpick on the coding style ;-)

Comment thread Lib/test/test_clinic.py Outdated
Comment thread Tools/clinic/clinic.py Outdated
AlexWaygood enabled auto-merge (squash) August 28, 2023 17:39

Copy link
Copy Markdown
Member Author

Thanks for the reviews!

This comment was marked as spam.

AlexWaygood deleted the improve-parse-file branch August 28, 2023 18:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL