vmprof / vmprof-python

vmprof - a statistical program profiler
https://vmprof.readthedocs.io
Other
433 stars 55 forks source link

jitlog/objects.py iter_ranges() broken on Python 2.7 #188

Closed ejona86 closed 1 month ago

ejona86 commented 5 years ago

PEP 479 changed the behavior of generators such that raising StopException would produce an actual exception instead of marking the end. Instead, you should simply return. As can be seen from the transition plan, the new behavior was made default in Python 2.7.

============================= test session starts ==============================
platform linux -- Python 3.7.2, pytest-4.1.0, py-1.7.0, pluggy-0.8.0
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/build/python-vmprof/src/vmprof-python-0.4.12/.hypothesis/examples')
rootdir: /build/python-vmprof/src/vmprof-python-0.4.12, inifile: pytest.ini
plugins: hypothesis-3.86.6
collected 62 items

jitlog/test/test_encoding.py ...                                         [  4%]
jitlog/test/test_jitlog.py ..........F.........                          [ 37%]
jitlog/test/test_query.py .....                                          [ 45%]
vmprof/test/test_c_source.py ....s.                                      [ 54%]
vmprof/test/test_c_symboltable.py ..                                     [ 58%]
vmprof/test/test_config.py ...                                           [ 62%]
vmprof/test/test_reader.py ..                                            [ 66%]
vmprof/test/test_run.py ........XXXX......                               [ 95%]
vmprof/test/test_stats.py ..s                                            [100%]

=================================== FAILURES ===================================
_______________________________ test_iter_ranges _______________________________

numbers = []

    def iter_ranges(numbers):
        if len(numbers) == 0:
>           raise StopIteration
E           StopIteration

jitlog/objects.py:374: StopIteration

The above exception was the direct cause of the following exception:

    def test_iter_ranges():
        r = lambda a,b: list(range(a,b))
        if PY3:
            r = range
>       assert list(iter_ranges([])) == []
E       RuntimeError: generator raised StopIteration

jitlog/test/test_jitlog.py:166: RuntimeError
=============================== warnings summary ===============================
jitlog/marks.py:103
  /build/python-vmprof/src/vmprof-python-0.4.12/jitlog/marks.py:103: DeprecationWarning: invalid escape sequence \(
    TOKEN_REGEX = re.compile("TargetToken\((\d+)\)")

vmprof/test/test_config.py::test_parser_config
  /build/python-vmprof/src/vmprof-python-0.4.12/vmprof/cli.py:114: DeprecationWarning: This method will be removed in future versions.  Use 'parser.read_file()' instead.
    self.ini_parser.readfp(f)

vmprof/test/test_config.py::test_parser_arg_precedence
  /build/python-vmprof/src/vmprof-python-0.4.12/vmprof/cli.py:114: DeprecationWarning: This method will be removed in future versions.  Use 'parser.read_file()' instead.
    self.ini_parser.readfp(f)

vmprof/test/test_config.py::test_parser_without_section
  /build/python-vmprof/src/vmprof-python-0.4.12/vmprof/cli.py:114: DeprecationWarning: This method will be removed in future versions.  Use 'parser.read_file()' instead.
    self.ini_parser.readfp(f)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
==== 1 failed, 55 passed, 2 skipped, 4 xpassed, 4 warnings in 12.29 seconds ====
mattip commented 1 month ago

Fixed in af342e5