File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 88
99
1010__all__ = 'Map' ,
11- __version__ = '0.4 '
11+ __version__ = '0.5 '
Original file line number Diff line number Diff line change @@ -2679,6 +2679,14 @@ map_dump(MapObject *self);
26792679static PyObject *
26802680map_tp_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
26812681{
2682+ if (kwds != NULL && PyDict_Size (kwds ) != 0 ) {
2683+ PyErr_SetString (PyExc_TypeError , "__new__ takes no keyword arguments" );
2684+ return NULL ;
2685+ }
2686+ if (args != NULL && PyTuple_Size (args ) != 0 ) {
2687+ PyErr_SetString (PyExc_TypeError , "__new__ takes no positional arguments" );
2688+ return NULL ;
2689+ }
26822690 return (PyObject * )map_new ();
26832691}
26842692
Original file line number Diff line number Diff line change @@ -93,6 +93,13 @@ class BaseMapTest:
9393
9494 Map = None
9595
96+ def test_init_no_args (self ):
97+ with self .assertRaisesRegex (TypeError , 'positional argument' ):
98+ self .Map (dict (a = 1 ))
99+
100+ with self .assertRaisesRegex (TypeError , 'keyword argument' ):
101+ self .Map (a = 1 )
102+
96103 def test_hashkey_helper_1 (self ):
97104 k1 = HashKey (10 , 'aaa' )
98105 k2 = HashKey (10 , 'bbb' )
You can’t perform that action at this time.
0 commit comments