mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Issue #9551: Do not raise TypeError when setting the value to None for
SafeConfigParser instances constructed with allow_no_value == True.
This commit is contained in:
		
							parent
							
								
									2d930804ff
								
							
						
					
					
						commit
						0a1fa0e8b1
					
				
					 3 changed files with 15 additions and 9 deletions
				
			
		|  | @ -699,13 +699,13 @@ def set(self, section, option, value=None): | |||
|         if self._optcre is self.OPTCRE or value: | ||||
|             if not isinstance(value, basestring): | ||||
|                 raise TypeError("option values must be strings") | ||||
|         # check for bad percent signs: | ||||
|         # first, replace all "good" interpolations | ||||
|         tmp_value = value.replace('%%', '') | ||||
|         tmp_value = self._interpvar_re.sub('', tmp_value) | ||||
|         # then, check if there's a lone percent sign left | ||||
|         percent_index = tmp_value.find('%') | ||||
|         if percent_index != -1: | ||||
|             raise ValueError("invalid interpolation syntax in %r at " | ||||
|                              "position %d" % (value, percent_index)) | ||||
|         if value is not None: | ||||
|             # check for bad percent signs: | ||||
|             # first, replace all "good" interpolations | ||||
|             tmp_value = value.replace('%%', '') | ||||
|             tmp_value = self._interpvar_re.sub('', tmp_value) | ||||
|             # then, check if there's a lone percent sign left | ||||
|             if '%' in tmp_value: | ||||
|                 raise ValueError("invalid interpolation syntax in %r at " | ||||
|                                 "position %d" % (value, tmp_value.find('%'))) | ||||
|         ConfigParser.set(self, section, option, value) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Fred Drake
						Fred Drake