File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -1767,6 +1767,9 @@ def test_update(self):
17671767 self .assertEqual (copy , frozendict ({'x' : 1 }))
17681768
17691769 def test_repr (self ):
1770+ d = frozendict ()
1771+ self .assertEqual (repr (d ), "frozendict()" )
1772+
17701773 d = frozendict (x = 1 , y = 2 )
17711774 self .assertEqual (repr (d ), "frozendict({'x': 1, 'y': 2})" )
17721775
Original file line number Diff line number Diff line change @@ -7868,6 +7868,11 @@ static PyMethodDef frozendict_methods[] = {
78687868static PyObject *
78697869frozendict_repr (PyObject * self )
78707870{
7871+ PyDictObject * mp = _PyAnyDict_CAST (self );
7872+ if (mp -> ma_used == 0 ) {
7873+ return PyUnicode_FromFormat ("%s()" , Py_TYPE (self )-> tp_name );
7874+ }
7875+
78717876 PyObject * repr = anydict_repr_impl (self );
78727877 if (repr == NULL ) {
78737878 return NULL ;
You can’t perform that action at this time.
0 commit comments