| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| Expand Up | @@ -1250,18 +1250,32 @@ def parser_body( | |||||
| parser_prototype = self.PARSER_PROTOTYPE_VARARGS | ||||||
| parser_definition = parser_body(parser_prototype, ' {option_group_parsing}') | ||||||
|
|
||||||
| elif not requires_defining_class and pos_only == len(parameters) - pseudo_args and clinic.limited_capi: | ||||||
| # positional-only for the limited C API | ||||||
| flags = "METH_VARARGS" | ||||||
| elif clinic.limited_capi: | ||||||
| if not requires_defining_class and pos_only == len(parameters) - pseudo_args: | ||||||
| # positional-only for the limited C API: | ||||||
| # PyArg_ParseTuple() | ||||||
| flags = "METH_VARARGS" | ||||||
|
|
||||||
| parser_prototype = self.PARSER_PROTOTYPE_VARARGS | ||||||
| parser_code = [normalize_snippet(""" | ||||||
| if (!PyArg_ParseTuple(args, "{format_units}:{name}", | ||||||
| {parse_arguments})) | ||||||
| goto exit; | ||||||
| """, indent=4)] | ||||||
| argname_fmt = 'args[%d]' | ||||||
| declarations = "" | ||||||
| parser_prototype = self.PARSER_PROTOTYPE_VARARGS | ||||||
| parser_code = [normalize_snippet(""" | ||||||
| if (!PyArg_ParseTuple(args, "{format_units}:{name}", | ||||||
| {parse_arguments})) | ||||||
| goto exit; | ||||||
| """, indent=4)] | ||||||
| declarations = "" | ||||||
|
|
||||||
| else: | ||||||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityDoes it work if requires_defining_class is true?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityNo, it doesn't. This change is incomplete, it can be completed later. Or do you mean that an exception should be raised instead of an compilation error?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCurrently it can produce invalid code which is compiled. There are two opposite approaches:
I am currently trying the second approach. It allows to re-generate all clinic code using the limited API and test that at least it works (I found many cases in which the current code does not generate working code). Please hold this PR, the current code is more suitable for this experiment. After testing it will be easy to switch to the first approach.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityA module targeting the limited C API cannot use the private API. It fails at build.
Sorry, something went wrong.
All reactions
|
||||||
| # positional-or-keyword arguments for the limited C API: | ||||||
| # PyArg_ParseTupleAndKeywords() | ||||||
| flags = "METH_VARARGS|METH_KEYWORDS" | ||||||
|
|
||||||
| parser_prototype = self.PARSER_PROTOTYPE_KEYWORD | ||||||
| parser_code = [normalize_snippet(""" | ||||||
| if (!PyArg_ParseTupleAndKeywords(args, kwargs, "{format_units}:{name}", _keywords, | ||||||
| {parse_arguments})) | ||||||
| goto exit; | ||||||
| """, indent=4)] | ||||||
| declarations = "char* _keywords[] = {{{keywords_c} NULL}};" | ||||||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI don't reallly understand the difference between the two. The value is constant so the variable should not really exist on the stack, no?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThere is a difference. It is an array of pointers. If it is a local variable, it should fill with initial values every time the function is called. If it is a static variable, it is only filled with initial values at the program's start (or when the function is called first time).
Sorry, something went wrong.
erlend-aasland reacted with thumbs up emoji
All reactions
|
||||||
|
|
||||||
| parser_definition = parser_body(parser_prototype, *parser_code, | ||||||
| declarations=declarations) | ||||||
| Expand Down Expand Up | @@ -1384,20 +1398,7 @@ def parser_body( | |||||
| ) | ||||||
| nargs = f"Py_MIN(nargs, {max_pos})" if max_pos else "0" | ||||||
|
|
||||||
| if clinic.limited_capi: | ||||||
| # positional-or-keyword arguments | ||||||
| flags = "METH_VARARGS|METH_KEYWORDS" | ||||||
|
|
||||||
| parser_prototype = self.PARSER_PROTOTYPE_KEYWORD | ||||||
| parser_code = [normalize_snippet(""" | ||||||
| if (!PyArg_ParseTupleAndKeywords(args, kwargs, "{format_units}:{name}", _keywords, | ||||||
| {parse_arguments})) | ||||||
| goto exit; | ||||||
| """, indent=4)] | ||||||
| argname_fmt = 'args[%d]' | ||||||
| declarations = "" | ||||||
|
|
||||||
| elif not new_or_init: | ||||||
| if not new_or_init: | ||||||
| flags = "METH_FASTCALL|METH_KEYWORDS" | ||||||
| parser_prototype = self.PARSER_PROTOTYPE_FASTCALL_KEYWORDS | ||||||
| argname_fmt = 'args[%d]' | ||||||
| Expand Down | ||||||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
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 QualityDoes it work if pseudo_args is not zero?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 QualityI have no idea. I don't know what are pseudo args.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.