File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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-
380375class 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
Original file line number Diff line number Diff 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.
181178MISSING = sentinel ("MISSING" )
Original file line number Diff line number Diff 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
145141def _parse_value_tb (exc , value , tb ):
146142 if (value is _sentinel ) != (tb is _sentinel ):
You can’t perform that action at this time.
0 commit comments