Explicitly restrict prelude imports.

It turns out that while Python does not import _private identifiers
when using * imports, it does nevertheless import all submodules.

Avoid polluting the namespace in the prelude by explicitly listing
all exported identifiers.
This commit is contained in:
whitequark 2019-10-21 10:39:21 +00:00
parent 9fba5ccb51
commit 61e6267daf
2 changed files with 28 additions and 1 deletions

View file

@ -4,4 +4,18 @@ try:
except pkg_resources.DistributionNotFound: except pkg_resources.DistributionNotFound:
pass pass
from .hdl import * from .hdl import *
__all__ = [
"Shape", "unsigned", "signed",
"Value", "Const", "C", "Mux", "Cat", "Repl", "Array", "Signal", "ClockSignal", "ResetSignal",
"Module",
"ClockDomain",
"Elaboratable", "Fragment", "Instance",
"Memory",
"Record",
"DomainRenamer", "ResetInserter", "EnableInserter",
"CEInserter", # TODO(nmigen-0.2): remove this
]

View file

@ -6,4 +6,17 @@ from .ir import Elaboratable, Fragment, Instance
from .mem import Memory from .mem import Memory
from .rec import Record from .rec import Record
from .xfrm import DomainRenamer, ResetInserter, EnableInserter, \ from .xfrm import DomainRenamer, ResetInserter, EnableInserter, \
CEInserter # deprecated CEInserter # TODO(nmigen-0.2): remove this
__all__ = [
"Shape", "unsigned", "signed",
"Value", "Const", "C", "Mux", "Cat", "Repl", "Array", "Signal", "ClockSignal", "ResetSignal",
"Module",
"ClockDomain",
"Elaboratable", "Fragment", "Instance",
"Memory",
"Record",
"DomainRenamer", "ResetInserter", "EnableInserter",
"CEInserter", # TODO(nmigen-0.2): remove this
]