Skip to content

Commit 422425f

Browse files
Restore compatibility with Python 3.9's legacy LL(1) parser
The legacy LL(1) parser cannot handle compound with-statements using grouping parentheses and the `EXPR as TARGET` syntax, because it is not LL(1)-recognizable. This partially reverts commit f151eec.
1 parent fc32d66 commit 422425f

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ their individual contributions.
120120
* `Louis Taylor <https://github.com/kragniz>`_
121121
* `Luke Barone-Adesi <https://github.com/baluke>`_
122122
* `Lundy Bernard <https://github.com/lundybernard>`_
123+
* `Marco Ricci <https://github.com/the-13th-letter>`_
123124
* `Marco Sirabella <https://www.github.com/mjsir911>`_
124125
* `marekventur <https://www.github.com/marekventur>`_
125126
* `Marius Gedminas <https://www.github.com/mgedmin>`_ ([email protected])

hypothesis-python/RELEASE.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
RELEASE_TYPE: patch
2+
3+
This patch restores compatibility when using `the legacy Python 3.9 LL(1)
4+
parser <https://docs.python.org/3/whatsnew/3.9.html#new-parser>`__, which
5+
was accidentally broken since :ref:`version 6.130.13 <v6.130.13>`.
6+
7+
Thanks to Marco Ricci for this fix!

hypothesis-python/src/hypothesis/core.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,18 +1102,19 @@ def run(data: ConjectureData) -> None:
11021102

11031103
# self.test_runner can include the execute_example method, or setup/teardown
11041104
# _example, so it's important to get the PRNG and build context in place first.
1105-
with (
1106-
local_settings(self.settings),
1107-
deterministic_PRNG(),
1108-
BuildContext(data, is_final=is_final) as context,
1109-
):
1110-
# providers may throw in per_case_context_fn, and we'd like
1111-
# `result` to still be set in these cases.
1112-
result = None
1113-
with data.provider.per_test_case_context_manager():
1114-
# Run the test function once, via the executor hook.
1115-
# In most cases this will delegate straight to `run(data)`.
1116-
result = self.test_runner(data, run)
1105+
#
1106+
# NOTE: For compatibility with Python 3.9's LL(1) parser, this is written as
1107+
# three nested with-statements, instead of one compound statement.
1108+
with local_settings(self.settings):
1109+
with deterministic_PRNG():
1110+
with BuildContext(data, is_final=is_final) as context:
1111+
# providers may throw in per_case_context_fn, and we'd like
1112+
# `result` to still be set in these cases.
1113+
result = None
1114+
with data.provider.per_test_case_context_manager():
1115+
# Run the test function once, via the executor hook.
1116+
# In most cases this will delegate straight to `run(data)`.
1117+
result = self.test_runner(data, run)
11171118

11181119
# If a failure was expected, it should have been raised already, so
11191120
# instead raise an appropriate diagnostic error.

0 commit comments

Comments
 (0)