Skip to content

Commit 685054d

Browse files
committed
Editorial pass.
1 parent 9300474 commit 685054d

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

‎peps/pep-0842.rst‎

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,8 @@ that provide access to native functionality or otherwise speed up the module
188188
in some way. These native modules are often prefixed with a leading underscore.
189189

190190
For example, in :term:`CPython`, the :mod:`asyncio` module has a private
191-
``_asyncio`` accelerator module, so a trained eye, reading ``_asyncio``
192-
in Python code may read as accessing the C accelerator. This requires the
193-
reviewer to find where the import is defined as determine which version
194-
of ``asyncio`` is being used.
191+
``_asyncio`` accelerator module, so a reader seeing ``_asyncio`` may take it
192+
to mean the C accelerator and not the normal module.
195193

196194

197195
Imports are suggested by language servers and linters
@@ -226,7 +224,7 @@ In Python 3.7, an import to the :mod:`errno` module was removed from :mod:`os`.
226224
This caused a lot of breakage:
227225

228226
* `python/cpython#77847 <https://github.com/python/cpython/issues/77847>`__
229-
* `Qiskit/quiskit#1253 <https://github.com/Qiskit/qiskit/issues/1253>`__
227+
* `Qiskit/qiskit#1253 <https://github.com/Qiskit/qiskit/issues/1253>`__
230228
* `uxlfoundation/oneMath#68 <https://github.com/uxlfoundation/oneMath/issues/68>`__
231229
* `intel/bmap-tools#34 <https://github.com/intel/bmap-tools/issues/34>`__
232230
* `Red Hat Bug 1583196 <https://bugzilla.redhat.com/show_bug.cgi?id=1583196>`__
@@ -275,7 +273,7 @@ Linters cannot fight against imports
275273

276274
As a solution to the above problem, one might suggest that linters should
277275
simply warn against importing modules from another module. The primary issue
278-
with this is that this pattern is particular common in ``__init__.py`` files
276+
with this is that this pattern is particularly common in ``__init__.py`` files
279277
to move all packages into one namespace. For example:
280278

281279
.. code-block::
@@ -721,6 +719,10 @@ The grammar is changed to allow for the standalone ``export`` statement and
721719
| &"export" export_stmt
722720
723721
722+
Note that augmented assignments (``x += y``) are disallowed through a PEG action
723+
at compile time.
724+
725+
724726
Standalone exports
725727
******************
726728

@@ -748,13 +750,6 @@ is semantically equivalent to:
748750
if "NAME1" not in globals():
749751
raise NameError(...)
750752
751-
try:
752-
__export__
753-
except NameError:
754-
__export__ = []
755-
756-
__export__.append("NAME1")
757-
758753
if "NAME2" not in globals():
759754
raise NameError(...)
760755
@@ -763,6 +758,7 @@ is semantically equivalent to:
763758
except NameError:
764759
__export__ = []
765760
761+
__export__.append("NAME1")
766762
__export__.append("NAME2")
767763
768764
@@ -781,7 +777,7 @@ As an example, the following code:
781777

782778
.. code-block:: python+soft-keywords:export
783779

784-
export NAME, NAME2 = VALUE1, VALUE2
780+
export NAME1, NAME2 = VALUE1, VALUE2
785781

786782
is semantically equivalent to:
787783

@@ -961,6 +957,16 @@ It does *not* break backwards compatibility, meaning that existing code using
961957
"``export``" as a variable name will continue to work.
962958

963959

960+
Relation to ``-W error``
961+
------------------------
962+
963+
While this PEP does not break any existing applications, it may break
964+
tests for downstream users of packages who choose to adopt this PEP, as
965+
many popular testing frameworks, such as `pytest
966+
<https://docs.pytest.org/en/stable/>`__, run with warnings-as-errors enabled
967+
by default.
968+
969+
964970
Security Implications
965971
=====================
966972

@@ -1133,7 +1139,8 @@ syntax. For example:
11331139
11341140
This is the author's next preferred solution after ``export`` syntax, but it
11351141
does come with some caveats. In particular, there's no easy way to export
1136-
simple variables without duplicating
1142+
simple variables without duplicating the name, which many dislike due to the
1143+
violation of the DRY principle.
11371144

11381145

11391146
Open Issues
@@ -1157,7 +1164,7 @@ Paul Moore, Steve Dower, and Barry Warsaw.
11571164
Change History
11581165
==============
11591166

1160-
* 06-Aug-2026
1167+
* 05-Aug-2026
11611168

11621169
- Added an ``export`` statement.
11631170
- Added the ``ExportWarning`` builtin type, which is now emitted instead of a

0 commit comments

Comments
 (0)