@@ -410,7 +410,7 @@ def _interpolate_some(self, parser, option, accum, rest, section, map,
410410 v = map [var ]
411411 except KeyError :
412412 raise InterpolationMissingOptionError (
413- option , section , rest , var )
413+ option , section , rest , var ) from None
414414 if "%" in v :
415415 self ._interpolate_some (parser , option , accum , v ,
416416 section , map , depth + 1 )
@@ -482,7 +482,7 @@ def _interpolate_some(self, parser, option, accum, rest, section, map,
482482 "More than one ':' found: %r" % (rest ,))
483483 except (KeyError , NoSectionError , NoOptionError ):
484484 raise InterpolationMissingOptionError (
485- option , section , rest , ":" .join (path ))
485+ option , section , rest , ":" .join (path )) from None
486486 if "$" in v :
487487 self ._interpolate_some (parser , opt , accum , v , sect ,
488488 dict (parser .items (sect , raw = True )),
@@ -515,7 +515,7 @@ def before_get(self, parser, section, option, value, vars):
515515 value = value % vars
516516 except KeyError as e :
517517 raise InterpolationMissingOptionError (
518- option , section , rawval , e .args [0 ])
518+ option , section , rawval , e .args [0 ]) from None
519519 else :
520520 break
521521 if value and "%(" in value :
@@ -647,7 +647,7 @@ def options(self, section):
647647 try :
648648 opts = self ._sections [section ].copy ()
649649 except KeyError :
650- raise NoSectionError (section )
650+ raise NoSectionError (section ) from None
651651 opts .update (self ._defaults )
652652 return list (opts .keys ())
653653
@@ -876,7 +876,7 @@ def set(self, section, option, value=None):
876876 try :
877877 sectdict = self ._sections [section ]
878878 except KeyError :
879- raise NoSectionError (section )
879+ raise NoSectionError (section ) from None
880880 sectdict [self .optionxform (option )] = value
881881
882882 def write (self , fp , space_around_delimiters = True ):
@@ -917,7 +917,7 @@ def remove_option(self, section, option):
917917 try :
918918 sectdict = self ._sections [section ]
919919 except KeyError :
920- raise NoSectionError (section )
920+ raise NoSectionError (section ) from None
921921 option = self .optionxform (option )
922922 existed = option in sectdict
923923 if existed :
0 commit comments