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

[3.11] gh-106970: Fix Argument Clinic 'destination <name> clear' command (#106972) by erlend-aasland · Pull Request #107059 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .py  (1) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
56 changes: 56 additions & 0 deletions Lib/test/clinic.test.c
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
Original file line number Diff line number Diff line change
Expand Up @@ -4192,3 +4192,59 @@ Test_meth_coexist(TestObj *self, PyObject *Py_UNUSED(ignored))
static PyObject *
Test_meth_coexist_impl(TestObj *self)
/*[clinic end generated code: output=808a293d0cd27439 input=2a1d75b5e6fec6dd]*/


/*[clinic input]
output push
output preset buffer
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=5bff3376ee0df0b5]*/

/*[clinic input]
buffer_clear
a: int
We'll call 'destination buffer clear' after this.

Argument Clinic's buffer preset puts most generated code into the
'buffer' destination, except from 'impl_definition', which is put into
the 'block' destination, so we should expect everything but
'impl_definition' to be cleared.
[clinic start generated code]*/

static PyObject *
buffer_clear_impl(PyObject *module, int a)
/*[clinic end generated code: output=f14bba74677e1846 input=a4c308a6fdab043c]*/

/*[clinic input]
destination buffer clear
output pop
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=f20d06adb8252084]*/


/*[clinic input]
output push
destination test1 new buffer
output everything suppress
output docstring_definition test1
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=5a77c454970992fc]*/

/*[clinic input]
new_dest
a: int
Only this docstring should be outputted to test1.
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=da5af421ed8996ed]*/

/*[clinic input]
dump test1
output pop
[clinic start generated code]*/

PyDoc_STRVAR(new_dest__doc__,
"new_dest($module, /, a)\n"
"--\n"
"\n"
"Only this docstring should be outputted to test1.");
/*[clinic end generated code: output=9cac703f51d90e84 input=090db8df4945576d]*/
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix bugs in the Argument Clinic ``destination <name> clear`` command; the
destination buffers would never be cleared, and the ``destination``
directive parser would simply continue to the fault handler after processing
the command. Patch by Erlend E. Aasland.
23 changes: 14 additions & 9 deletions Tools/clinic/clinic.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ def __getitem__(self, i):

def clear(self):
for ta in self._array:
ta._text.clear()
ta.text.clear()

def dump(self):
texts = [ta.output() for ta in self._array]
Expand Down Expand Up @@ -4121,14 +4121,19 @@ def directive_set(self, name, value):

self.clinic.__dict__[name] = value

def directive_destination(self, name, command, *args):
if command == 'new':
self.clinic.add_destination(name, *args)
return

if command == 'clear':
self.clinic.get_destination(name).clear()
fail("unknown destination command", repr(command))
def directive_destination(
self,
name: str,
command: str,
*args
) -> None:
match command:
case "new":
self.clinic.add_destination(name, *args)
case "clear":
self.clinic.get_destination(name).clear()
case _:
fail("unknown destination command", repr(command))


def directive_output(self, command_or_name, destination=''):
Expand Down

Back | FazBrowse Home | New Git URL