mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Fix issue 2782: be less strict about the format string type in strftime.
Accept unicode and anything else ParseTuple "s#" can deal with. This matches the time.strftime behavior.
This commit is contained in:
		
							parent
							
								
									8856ddae25
								
							
						
					
					
						commit
						137d824148
					
				
					 3 changed files with 32 additions and 21 deletions
				
			
		|  | @ -850,9 +850,13 @@ def test_strftime(self): | |||
|         self.assertRaises(TypeError, t.strftime, "one", "two") # too many args | ||||
|         self.assertRaises(TypeError, t.strftime, 42) # arg wrong type | ||||
| 
 | ||||
|         # test that unicode input is allowed (issue 2782) | ||||
|         self.assertEqual(t.strftime(u"%m"), "03") | ||||
| 
 | ||||
|         # A naive object replaces %z and %Z w/ empty strings. | ||||
|         self.assertEqual(t.strftime("'%z' '%Z'"), "'' ''") | ||||
| 
 | ||||
| 
 | ||||
|     def test_format(self): | ||||
|         dt = self.theclass(2007, 9, 10) | ||||
|         self.assertEqual(dt.__format__(''), str(dt)) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Gregory P. Smith
						Gregory P. Smith