diff --git a/Lib/tkinter/font.py b/Lib/tkinter/font.py index 15ad7ab4b63..a9f79d8e456 100644 --- a/Lib/tkinter/font.py +++ b/Lib/tkinter/font.py @@ -100,6 +100,10 @@ class Font: def __str__(self): return self.name + def __repr__(self): + return f"<{self.__class__.__module__}.{self.__class__.__qualname__}" \ + f" object {self.name!r}>" + def __eq__(self, other): if not isinstance(other, Font): return NotImplemented diff --git a/Lib/tkinter/test/test_tkinter/test_font.py b/Lib/tkinter/test/test_tkinter/test_font.py index a021ea33680..6d1eea44b4d 100644 --- a/Lib/tkinter/test/test_tkinter/test_font.py +++ b/Lib/tkinter/test/test_tkinter/test_font.py @@ -101,6 +101,12 @@ class FontTest(AbstractTkTest, unittest.TestCase): self.assertTrue(name) self.assertIn(fontname, names) + def test_repr(self): + self.assertEqual( + repr(self.font), f'' + ) + + tests_gui = (FontTest, ) if __name__ == "__main__": diff --git a/Misc/ACKS b/Misc/ACKS index 660b8ef7504..7f4a9bcbc0f 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1353,6 +1353,7 @@ Zero Piraeus Antoine Pitrou Jean-François Piéronne Oleg Plakhotnyuk +Anatoliy Platonov Marcel Plch Remi Pointel Jon Poler diff --git a/Misc/NEWS.d/next/Library/2020-09-29-16-23-54.bpo-41876.QicdDU.rst b/Misc/NEWS.d/next/Library/2020-09-29-16-23-54.bpo-41876.QicdDU.rst new file mode 100644 index 00000000000..d4f5f0a37bf --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-09-29-16-23-54.bpo-41876.QicdDU.rst @@ -0,0 +1 @@ +Tkinter font class repr uses font name \ No newline at end of file