8000 gh-108494: Argument Clinic: fix support of Limited C API by serhiy-storchaka · Pull Request #108536 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-108494: Argument Clinic: fix support of Limited C API #108536

New issue

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

Merged
merged 7 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-108494: Argument Clinic: fix support of limited C API
  • Loading branch information
serhiy-storchaka committed Aug 27, 2023
commit 1896045217430c3b3c41865f4c460fdf76b003c5
11 changes: 7 additions & 4 deletions Lib/test/test_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def test_varargs3(self):
self.assertRaisesRegex(TypeError, msg, int.from_bytes, b'a', 'little', False)

def test_varargs1min(self):
msg = r"get expected at least 1 argument, got 0"
msg = (r"get\(\) takes at least 1 argument \(0 given\)|"
Copy link
Member Author

Choose a reason for hiding this comment

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

PyArg_ParseTuple() produces slightly different error message.

r"get expected at least 1 argument, got 0")
self.assertRaisesRegex(TypeError, msg, {}.get)

msg = r"expected 1 argument, got 0"
Expand All @@ -76,11 +77,13 @@ def test_varargs2min(self):
self.assertRaisesRegex(TypeError, msg, getattr)

def test_varargs1max(self):
msg = r"input expected at most 1 argument, got 2"
msg = (r"input\(\) takes at most 1 argument \(2 given\)|"
r"input expected at most 1 argument, got 2")
self.assertRaisesRegex(TypeError, msg, input, 1, 2)

def test_varargs2max(self):
msg = r"get expected at most 2 arguments, got 3"
msg = (r"get\(\) takes at most 2 arguments \(3 given\)|"
r"get expected at most 2 arguments, got 3")
self.assertRaisesRegex(TypeError, msg, {}.get, 1, 2, 3)

def test_varargs1_kw(self):
Expand All @@ -96,7 +99,7 @@ def test_varargs3_kw(self):
self.assertRaisesRegex(TypeError, msg, bool, x=2)

def test_varargs4_kw(self):
msg = r"^list[.]index\(\) takes no keyword arguments$"
msg = r"^(list[.])?index\(\) takes no keyword arguments$"
self.assertRaisesRegex(TypeError, msg, [].index, x=2)

def test_varargs5_kw(self):
Expand Down
6 changes: 4 additions & 2 deletions Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2799,11 +2799,13 @@ class SecondFailedStrEnum(CustomStrEnum):
class ThirdFailedStrEnum(CustomStrEnum):
one = '1'
two = 2 # this will become '2'
with self.assertRaisesRegex(TypeError, '.encoding. must be str, not '):
with self.assertRaisesRegex(TypeError,
r"argument (2|'encoding') must be str, not "):
class ThirdFailedStrEnum(CustomStrEnum):
one = '1'
two = b'2', sys.getdefaultencoding
with self.assertRaisesRegex(TypeError, '.errors. must be str, not '):
with self.assertRaisesRegex(TypeError,
r"argument (3|'errors') must be str, not "):
class ThirdFailedStrEnum(CustomStrEnum):
one = '1'
two = b'2', 'ascii', 9
Expand Down
8 changes: 3 additions & 5 deletions Lib/test/test_pyexpat.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,10 @@ def test_legal(self):
expat.ParserCreate(namespace_separator=' ')

def test_illegal(self):
try:
with self.assertRaisesRegex(TypeError,
r"ParserCreate\(\) argument (2|'namespace_separator') "
r"must be str or None, not int"):
expat.ParserCreate(namespace_separator=42)
self.fail()
except TypeError as e:
self.assertEqual(str(e),
"ParserCreate() argument 'namespace_separator' must be str or None, not int")

try:
expat.ParserCreate(namespace_separator='too long')
Expand Down
1 change: 1 addition & 0 deletions Modules/_localemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This software comes with no warranty. Use at your own risk.

#include "Python.h"
#include "pycore_fileutils.h"
#include "pycore_pymem.h" // _PyMem_Strdup

#include <stdio.h>
#include <locale.h>
Expand Down
2 changes: 1 addition & 1 deletion Modules/_sqlite/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ load_functools_lru_cache(PyObject *module)
static PyMethodDef module_methods[] = {
PYSQLITE_ADAPT_METHODDEF
PYSQLITE_COMPLETE_STATEMENT_METHODDEF
PYSQLITE_CONNECT_METHODDEF
{"connect", _PyCFunction_CAST(pysqlite_connect), METH_FASTCALL|METH_KEYWORDS, pysqlite_connect__doc__},
PYSQLITE_ENABLE_CALLBACK_TRACE_METHODDEF
PYSQLITE_REGISTER_ADAPTER_METHODDEF
PYSQLITE_REGISTER_CONVERTER_METHODDEF
Expand Down
1 change: 1 addition & 0 deletions Modules/_tracemalloc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Python.h"
#include "pycore_tracemalloc.h" // _PyTraceMalloc_IsTracing

#include "clinic/_tracemalloc.c.h"

Expand Down
5 changes: 2 additions & 3 deletions Modules/clinic/_testclinic_limited.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
0