Skip to content
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
Prev Previous commit
Next Next commit
Make constructor's arguments optional, it produces more interesting o…
…utput.
  • Loading branch information
serhiy-storchaka committed Aug 15, 2023
commit b1300c73e79ee5e676d5f91d6639a19eb44f063a
16 changes: 8 additions & 8 deletions Lib/test/test_clinic.py
Comment thread
erlend-aasland marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -3171,39 +3171,39 @@ def test_cloned_func_with_converter_exception_message(self):

def test_depr_star_new(self):
cls = ac_tester.DeprStarNew
cls()
cls(a=None)
self.check_depr_star("'a'", cls, None)
Comment thread
serhiy-storchaka marked this conversation as resolved.
self.assertRaises(TypeError, cls)

def test_depr_star_new_cloned(self):
fn = ac_tester.DeprStarNew(a=None).cloned
fn = ac_tester.DeprStarNew().cloned
fn()
fn(a=None)
self.check_depr_star("'a'", fn, None, name='_testclinic.DeprStarNew.cloned')
self.assertRaises(TypeError, fn)

def test_depr_star_init(self):
cls = ac_tester.DeprStarInit
cls()
cls(a=None)
self.check_depr_star("'a'", cls, None)
self.assertRaises(TypeError, cls)

def test_depr_star_init_cloned(self):
fn = ac_tester.DeprStarInit(a=None).cloned
fn = ac_tester.DeprStarInit().cloned
fn()
fn(a=None)
self.check_depr_star("'a'", fn, None, name='_testclinic.DeprStarInit.cloned')
self.assertRaises(TypeError, fn)

def test_depr_kwd_new(self):
cls = ac_tester.DeprKwdNew
cls()
cls(None)
self.check_depr_kwd("'a'", cls, a=None)
self.assertRaises(TypeError, cls)

def test_depr_kwd_init(self):
cls = ac_tester.DeprKwdInit
cls()
cls(None)
self.check_depr_kwd("'a'", cls, a=None)
self.assertRaises(TypeError, cls)

def test_depr_star_pos0_len1(self):
fn = ac_tester.depr_star_pos0_len1
Expand Down
16 changes: 8 additions & 8 deletions Modules/_testclinic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1219,13 +1219,13 @@ class _testclinic.DeprStarNew "PyObject *" "PyObject"
@classmethod
_testclinic.DeprStarNew.__new__ as depr_star_new
* [from 3.14]
a: object
a: object = None
The deprecation message should use the class name instead of __new__.
[clinic start generated code]*/

static PyObject *
depr_star_new_impl(PyTypeObject *type, PyObject *a)
/*[clinic end generated code: output=bdbb36244f90cf46 input=f4ae7dafbc23c378]*/
/*[clinic end generated code: output=bdbb36244f90cf46 input=fdd640db964b4dc1]*/
{
return type->tp_alloc(type, 0);
}
Expand Down Expand Up @@ -1260,13 +1260,13 @@ static PyTypeObject DeprStarNew = {
class _testclinic.DeprStarInit "PyObject *" "PyObject"
_testclinic.DeprStarInit.__init__ as depr_star_init
* [from 3.14]
a: object
a: object = None
The deprecation message should use the class name instead of __init__.
[clinic start generated code]*/

static int
depr_star_init_impl(PyObject *self, PyObject *a)
/*[clinic end generated code: output=8d27b43c286d3ecc input=659ebc748d87fa86]*/
/*[clinic end generated code: output=8d27b43c286d3ecc input=5575b77229d5e2be]*/
{
return 0;
}
Expand Down Expand Up @@ -1302,14 +1302,14 @@ static PyTypeObject DeprStarInit = {
class _testclinic.DeprKwdNew "PyObject *" "PyObject"
@classmethod
_testclinic.DeprKwdNew.__new__ as depr_kwd_new
a: object
a: object = None
/ [from 3.14]
The deprecation message should use the class name instead of __new__.
[clinic start generated code]*/

static PyObject *
depr_kwd_new_impl(PyTypeObject *type, PyObject *a)
/*[clinic end generated code: output=618d07afc5616149 input=831cfc26b33703a6]*/
/*[clinic end generated code: output=618d07afc5616149 input=6c7d13c471013c10]*/
{
return type->tp_alloc(type, 0);
}
Expand All @@ -1326,14 +1326,14 @@ static PyTypeObject DeprKwdNew = {
/*[clinic input]
class _testclinic.DeprKwdInit "PyObject *" "PyObject"
_testclinic.DeprKwdInit.__init__ as depr_kwd_init
a: object
a: object = None
/ [from 3.14]
The deprecation message should use the class name instead of __init__.
[clinic start generated code]*/

static int
depr_kwd_init_impl(PyObject *self, PyObject *a)
/*[clinic end generated code: output=6e02eb724a85d840 input=2e85cfe2845593f6]*/
/*[clinic end generated code: output=6e02eb724a85d840 input=b9bf3c20f012d539]*/
{
return 0;
}
Expand Down
78 changes: 57 additions & 21 deletions Modules/clinic/_testclinic_depr_star.c.h
Comment thread
erlend-aasland marked this conversation as resolved.

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