diff options
author | Matti Picus <matti.picus@gmail.com> | 2018-07-11 09:25:35 -0500 |
---|---|---|
committer | Matti Picus <matti.picus@gmail.com> | 2018-07-11 09:25:35 -0500 |
commit | 2c6a99127f3679ef34448d337c2977dc55f31f66 (patch) | |
tree | 16de7728db54f3cfd8d190117c6cd7642dc48b14 /lib-python | |
parent | modify never used rpython surrogate_in_utf8 to return index (diff) | |
parent | fix translation (diff) | |
download | pypy-2c6a99127f3679ef34448d337c2977dc55f31f66.tar.gz pypy-2c6a99127f3679ef34448d337c2977dc55f31f66.tar.bz2 pypy-2c6a99127f3679ef34448d337c2977dc55f31f66.zip |
merge default into branch
Diffstat (limited to 'lib-python')
-rw-r--r-- | lib-python/2.7/code.py | 6 | ||||
-rw-r--r-- | lib-python/2.7/fractions.py | 9 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib-python/2.7/code.py b/lib-python/2.7/code.py index 3b39d1b346..a8290added 100644 --- a/lib-python/2.7/code.py +++ b/lib-python/2.7/code.py @@ -104,6 +104,12 @@ class InteractiveInterpreter: except SystemExit: raise except: + if softspace(sys.stdout, 0): + print + try: + sys.stdout.flush() + except: + pass self.showtraceback() else: if softspace(sys.stdout, 0): diff --git a/lib-python/2.7/fractions.py b/lib-python/2.7/fractions.py index a0d86a4393..76bcd91f3a 100644 --- a/lib-python/2.7/fractions.py +++ b/lib-python/2.7/fractions.py @@ -517,8 +517,13 @@ class Fraction(Rational): # Get integers right. return hash(self._numerator) # Expensive check, but definitely correct. - if self == float(self): - return hash(float(self)) + # PyPy: the following 4 lines used to be almost twice slower: + # if self == float(self): + # return hash(float(self)) + f = float(self) + x, y = f.as_integer_ratio() # signs are correct: y is positive + if self._numerator == x and self._denominator == y: + return hash(f) else: # Use tuple's hash to avoid a high collision rate on # simple fractions. |