Skip to content

Commit 35b6083

Browse files
committed
Use repr= now that we have it
1 parent 5d6df25 commit 35b6083

3 files changed

Lines changed: 3 additions & 15 deletions

File tree

Lib/configparser.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,6 @@ def __init__(self):
372372
Error.__init__(self, "Support for UNNAMED_SECTION is disabled.")
373373

374374

375-
class _UnnamedSection:
376-
377-
def __repr__(self):
378-
return "<UNNAMED_SECTION>"
379-
380375
class InvalidWriteError(Error):
381376
"""Raised when attempting to write data that the parser would read back differently.
382377
ex: writing a key which begins with the section header pattern would read back as a
@@ -386,7 +381,7 @@ def __init__(self, msg=''):
386381
Error.__init__(self, msg)
387382

388383

389-
UNNAMED_SECTION = _UnnamedSection()
384+
UNNAMED_SECTION = sentinel("UNNAMED_SECTION", repr="<UNNAMED_SECTION>")
390385

391386

392387
# Used in parser getters to indicate the default behaviour when a specific

Lib/dataclasses.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,7 @@ class FrozenInstanceError(AttributeError): pass
172172
# A sentinel object for default values to signal that a default
173173
# factory will be used. This is given a nice repr() which will appear
174174
# in the function signature of dataclasses' constructors.
175-
class _HAS_DEFAULT_FACTORY_CLASS:
176-
def __repr__(self):
177-
return '<factory>'
178-
_HAS_DEFAULT_FACTORY = _HAS_DEFAULT_FACTORY_CLASS()
175+
_HAS_DEFAULT_FACTORY = sentinel("_HAS_DEFAULT_FACTORY", repr="<factory>")
179176

180177
# A sentinel object to detect if a parameter is supplied or not.
181178
MISSING = sentinel("MISSING")

Lib/traceback.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,7 @@ def extract_tb(tb, limit=None):
136136
"another exception occurred:\n\n")
137137

138138

139-
class _Sentinel:
140-
def __repr__(self):
141-
return "<implicit>"
142-
143-
_sentinel = _Sentinel()
139+
_sentinel = sentinel("_sentinel", repr="<implicit>")
144140

145141
def _parse_value_tb(exc, value, tb):
146142
if (value is _sentinel) != (tb is _sentinel):

0 commit comments

Comments
 (0)