mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Fix test_datetime on system with 32-bit time_t
Issue #29100: Catch OverflowError in the new test_timestamp_limits() test.
This commit is contained in:
		
							parent
							
								
									b67f096738
								
							
						
					
					
						commit
						6f37e3645d
					
				
					 1 changed files with 7 additions and 3 deletions
				
			
		| 
						 | 
					@ -1993,9 +1993,13 @@ def test_timestamp_limits(self):
 | 
				
			||||||
        # minimum timestamp
 | 
					        # minimum timestamp
 | 
				
			||||||
        min_dt = self.theclass.min.replace(tzinfo=timezone.utc)
 | 
					        min_dt = self.theclass.min.replace(tzinfo=timezone.utc)
 | 
				
			||||||
        min_ts = min_dt.timestamp()
 | 
					        min_ts = min_dt.timestamp()
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
            # date 0001-01-01 00:00:00+00:00: timestamp=-62135596800
 | 
					            # date 0001-01-01 00:00:00+00:00: timestamp=-62135596800
 | 
				
			||||||
            self.assertEqual(self.theclass.fromtimestamp(min_ts, tz=timezone.utc),
 | 
					            self.assertEqual(self.theclass.fromtimestamp(min_ts, tz=timezone.utc),
 | 
				
			||||||
                             min_dt)
 | 
					                             min_dt)
 | 
				
			||||||
 | 
					        except OverflowError as exc:
 | 
				
			||||||
 | 
					            # the date 0001-01-01 doesn't fit into 32-bit time_t
 | 
				
			||||||
 | 
					            self.skipTest(str(exc))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # maximum timestamp: set seconds to zero to avoid rounding issues
 | 
					        # maximum timestamp: set seconds to zero to avoid rounding issues
 | 
				
			||||||
        max_dt = self.theclass.max.replace(tzinfo=timezone.utc,
 | 
					        max_dt = self.theclass.max.replace(tzinfo=timezone.utc,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue