mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	Merged revisions 69436 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r69436 | mark.dickinson | 2009-02-08 14:42:28 +0000 (Sun, 08 Feb 2009) | 10 lines Issue #789290: make sure that hash(2**63) == hash(2.**63) on 64-bit platforms. The previous code was fragile, depending on the twin accidents that: (1) in C, casting the double value 2.**63 to long returns the integer value -2**63, and (2) in Python, hash(-2**63) == hash(2**63). There's already a test for this in test_hash. ........
This commit is contained in:
		
							parent
							
								
									876185542d
								
							
						
					
					
						commit
						c96db47217
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		| 
						 | 
					@ -655,7 +655,7 @@ _Py_HashDouble(double v)
 | 
				
			||||||
	fractpart = modf(v, &intpart);
 | 
						fractpart = modf(v, &intpart);
 | 
				
			||||||
	if (fractpart == 0.0) {
 | 
						if (fractpart == 0.0) {
 | 
				
			||||||
		/* This must return the same hash as an equal int or long. */
 | 
							/* This must return the same hash as an equal int or long. */
 | 
				
			||||||
		if (intpart > LONG_MAX || -intpart > LONG_MAX) {
 | 
							if (intpart > LONG_MAX/2 || -intpart > LONG_MAX/2) {
 | 
				
			||||||
			/* Convert to long and use its hash. */
 | 
								/* Convert to long and use its hash. */
 | 
				
			||||||
			PyObject *plong;	/* converted to Python long */
 | 
								PyObject *plong;	/* converted to Python long */
 | 
				
			||||||
			if (Py_IS_INFINITY(intpart))
 | 
								if (Py_IS_INFINITY(intpart))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue