@@ -758,7 +758,6 @@ def read(self, filenames, encoding=None):
758758 if isinstance (filename , os .PathLike ):
759759 filename = os .fspath (filename )
760760 read_ok .append (filename )
761- self ._loaded_sources .append (read_ok )
762761 return read_ok
763762
764763 def read_file (self , f , source = None ):
@@ -775,7 +774,6 @@ def read_file(self, f, source=None):
775774 except AttributeError :
776775 source = '<???>'
777776 self ._read (f , source )
778- self ._loaded_sources .append (source )
779777
780778 def read_string (self , string , source = '<string>' ):
781779 """Read configuration from a given string."""
@@ -812,7 +810,6 @@ def read_dict(self, dictionary, source='<dict>'):
812810 raise DuplicateOptionError (section , key , source )
813811 elements_added .add ((section , key ))
814812 self .set (section , key , value )
815- self ._loaded_sources .append (source )
816813
817814 def get (self , section , option , * , raw = False , vars = None , fallback = _UNSET ):
818815 """Get an option value for a given section.
@@ -1060,7 +1057,7 @@ def __str__(self):
10601057 return f"<ConfigParser: { config_dict } >"
10611058
10621059 def __repr__ (self ):
1063- init_params = {
1060+ params = {
10641061 "defaults" : self ._defaults if self ._defaults else None ,
10651062 "dict_type" : type (self ._dict ).__name__ ,
10661063 "allow_no_value" : self ._allow_no_value ,
@@ -1069,20 +1066,20 @@ def __repr__(self):
10691066 "default_section" : self .default_section ,
10701067 "interpolation" : type (self ._interpolation ).__name__ ,
10711068 }
1072- init_params = {k : v for k , v in init_params .items () if v is not None }
1069+ params = {k : v for k , v in params .items () if v is not None }
10731070 sections_count = len (self ._sections )
1074- state_summary = {
1071+ state = {
10751072 "loaded_sources" : self ._loaded_sources ,
10761073 "sections_count" : sections_count ,
10771074 "sections" : list (self ._sections )[:5 ], # limit to 5 section names for readability
10781075 }
10791076
10801077 if sections_count > 5 :
1081- state_summary ["sections_truncated" ] = f"...and { sections_count - 5 } more"
1078+ state ["sections_truncated" ] = f"...and { sections_count - 5 } more"
10821079
10831080 return (f"<{ self .__class__ .__name__ } ("
1084- f"params={ init_params } , "
1085- f"state={ state_summary } )>" )
1081+ f"params={ params } , "
1082+ f"state={ state } )>" )
10861083
10871084 def _read (self , fp , fpname ):
10881085 """Parse a sectioned configuration file.
@@ -1104,6 +1101,7 @@ def _read(self, fp, fpname):
11041101 try :
11051102 ParsingError ._raise_all (self ._read_inner (fp , fpname ))
11061103 finally :
1104+ self ._loaded_sources .append (fpname )
11071105 self ._join_multiline_values ()
11081106
11091107 def _read_inner (self , fp , fpname ):
0 commit comments