Skip to content

Commit

Permalink
gh-113317: Remove Argument Clinic global variable 'clinic'
Browse files Browse the repository at this point in the history
* Add Clinic.warn() and Clinic.fail() methods.
* Add filename parameter to BlockParser constructor.
* Add BlockParser.fail() method.
* Add DSLParser.fail() method.
* Pass lineno parameter to DSLParser.format_docstring(): more
  accurate error reporting.
* Convert a few DSLParser static methods to regular method to be able
  to call self.fail().
* Language.render() clinic parameter is now required: None is no
  longer accepted.
* Remove warn() function.
* Remove global variable 'clinic'.

fail() and warn() methods get filename and line number from the
instance on which the method is called, rather than relying on a
global variable 'clinic'.
  • Loading branch information
vstinner committed Jan 30, 2024
1 parent e21754d commit bb0ec1a
Show file tree
Hide file tree
Showing 2 changed files with 186 additions and 171 deletions.
4 changes: 2 additions & 2 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,7 @@ def test_state_func_docstring_no_summary(self):
docstring1
docstring2
"""
self.expect_failure(block, err, lineno=0)
self.expect_failure(block, err, lineno=3)

def test_state_func_docstring_only_one_param_template(self):
err = "You may not specify {parameters} more than once in a docstring!"
Expand All @@ -2404,7 +2404,7 @@ def test_state_func_docstring_only_one_param_template(self):
these are the params again:
{parameters}
"""
self.expect_failure(block, err, lineno=0)
self.expect_failure(block, err, lineno=7)


class ClinicExternalTest(TestCase):
Expand Down
Loading

0 comments on commit bb0ec1a

Please sign in to comment.