Skip to content

Commit 0f1703a

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 0f1703a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Amaranth HDL (previously nMigen)
1+
# Amaranth HDL (previously nMigen)
22

33
The Amaranth project provides an open-source toolchain for developing hardware based on synchronous digital logic using the Python programming language, as well as [evaluation board definitions][amaranth-boards], a [System on Chip toolkit][amaranth-soc], and more. It aims to be easy to learn and use, reduce or eliminate common coding mistakes, and simplify the design of complex hardware with reusable components.
44

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)