Skip to content

Commit 266dd4b

Browse files
Jean THOMASjeanthom
Jean THOMAS
authored andcommitted
docs: lang: fix build with PYTHONWARNINGS=error after Sphinx update.
Backported from 556faea
1 parent 58dd088 commit 266dd4b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/lang.rst

+13
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ Specifying a shape with a range is convenient for counters, indexes, and all oth
172172

173173
Python ranges are *exclusive* or *half-open*, meaning they do not contain their ``.stop`` element. Because of this, values with shapes cast from a ``range(stop)`` where ``stop`` is a power of 2 are not wide enough to represent ``stop`` itself:
174174

175+
.. doctest::
176+
:hide:
177+
178+
>>> import warnings
179+
>>> _warning_filters_backup = warnings.catch_warnings()
180+
>>> _warning_filters_backup.__enter__() # have to do this horrific hack to make it work with `PYTHONWARNINGS=error` :(
181+
>>> warnings.simplefilter("default", amaranth.hdl.dsl.SyntaxWarning)
182+
175183
.. doctest::
176184

177185
>>> fencepost = C(256, range(256))
@@ -182,6 +190,11 @@ Specifying a shape with a range is convenient for counters, indexes, and all oth
182190
>>> fencepost.value
183191
0
184192

193+
.. doctest::
194+
:hide:
195+
196+
>>> _warning_filters_backup.__exit__()
197+
185198
Amaranth detects uses of :class:`Const` and :class:`Signal` that invoke such an off-by-one error, and emits a diagnostic message.
186199

187200
.. note::

0 commit comments

Comments
 (0)