* rustpython_vm::import::import_source
* always print exceptions when panic by expect_pyresult
if users want simple panic, Result::expect could be used.
Context managers have an `__exit__` function that returns a boolean-like
object. If the object is truthy, then exceptions are suppressed.
If an exception was thrown while resolving that boolean, it would leak
and live on in the error stack, getting tacked on to all future
exceptions. This caused several mysterious test failures which would
only trigger after this very specific event was tested in `test_with`.
The solution is to move a call to `vm.set_exception()` before
attempting the `try_to_bool()` which threw the error.
Minimal example to reproduce the bug:
```py
import sys
import traceback
class cm(object):
def __init__(self):
pass
def __enter__(self):
return 3
def __exit__(self, a, b, c):
class Bool:
def __bool__(self):
1 // 0
return Bool()
try:
with cm():
raise Exception("Should NOT see this")
except ZeroDivisionError:
print("exception caught, as expected")
print("There should now be no exception")
traceback.print_exc()
print(sys.exc_info())
```
The original hash algorithm just XOR'd all the hashes of the elements of
the set, which is problematic. The CPython algorithm is required to pass
the tests.
- Replace `PyFrozenSet::hash` with CPython's algorithm
- Remove unused `hash_iter_unorded` functions
- Add `frozenset` benchmark
- Enable tests
- Lower performance expectations on effectiveness test
- Adjust `slot::hash_wrapper` so that it doesn't rehash the computed
hash value in the process of converting PyInt to PyHash.
Python does not define `list().__bool__`, `dict().__bool__`, and
`str().__bool__`, and some tests were failing because they were
defined.
I could not find any references to them and deleting them doesn't
seem to break anything.
The [docs](https://docs.python.org/3/library/functions.html#round)
specify that calling `round` with a negative precision removes
significant digits, so that `round(12345, -2) == 12300`. The
implementation was simply returning the original integer.
Additionally, `round(a, b)` is implemented as `(a / 10^b) * 10^b`, using
half-even rounding during the division.