Assert Error in AstHelper.py in python3.9 (Mac+Homebrew)

22 views
Skip to first unread message

Sebastian

unread,
Nov 21, 2020, 12:37:02 PM11/21/20
to pymtl-users
Hi Guys,

This may be very specific to my system (OS X Catalina), but I am flagging it just in case it might be of help.

In a virtual environment started with my Mac's native python (Python 3.7) I have a simulation go fine (code example below).
But in a virtual environment started with a Homebrew python (Python 3.9) I get an Assertion error (traceback below sign-off) for exactly the same code.

Design Code: 
from pymtl3 import *
from pymtl3.passes.backends.verilog import VerilogPlaceholderPass, VerilogPlaceholder
from os.path import dirname
class RegIncrVRTL( Component, VerilogPlaceholder ):
  def construct( s ):
    s.in_ = InPort( 8 )
    s.out = OutPort( 8 )
    s.set_metadata( VerilogPlaceholderPass.src_file, dirname(__file__)+'/RegIncrVRTL.v' )
    s.set_metadata( VerilogPlaceholderPass.top_module, 'RegIncrVRTL' )
RegIncrRTL = RegIncrVRTL

Test Code:
from pymtl3             import *
from pymtl3.stdlib.test_utils import run_test_vector_sim
from .RegIncrRTL2        import RegIncrRTL
def test_small( cmdline_opts ):
  run_test_vector_sim( RegIncrRTL(), [
    ('in_   out*'),
    [ 0x00, '?' ],
    [ 0x03, '?' ],
    [ 0x06, '?' ],
    [ 0x00, 0x07 ],
  ], cmdline_opts )


Best, Sebastian

Error trace:

../regincr/RegIncrRTL2_test.py::test_small FAILED


===================================================================== FAILURES =====================================================================

____________________________________________________________________ test_small ____________________________________________________________________

../regincr/RegIncrRTL2_test.py:18: in test_small

    run_test_vector_sim( RegIncrRTL(), [

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/stdlib/test_utils/test_helpers.py:213: in run_test_vector_sim

    model = config_model_with_cmdline_opts( model, cmdline_opts, [] )

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/stdlib/test_utils/test_helpers.py:94: in config_model_with_cmdline_opts

    top = VerilogTranslationImportPass()( top )

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/passes/backends/verilog/VerilogTranslationImportPass.py:37: in __call__

    return c.get_import_pass()()( top )

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/passes/backends/verilog/import_/VerilogVerilatorImportPass.py:250: in __call__

    ret.elaborate()

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/dsl/Component.py:448: in elaborate

    super().elaborate()

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/dsl/ComponentLevel2.py:615: in elaborate

    s._elaborate_construct()

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/dsl/NamedObject.py:384: in _elaborate_construct

    s._construct()

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/dsl/Component.py:69: in _construct

    s.construct( *s._dsl.args, **kwargs )

RegIncrVRTL_noparam_v.py:143: in construct

    def comb_upblk():

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/dsl/ComponentLevel1.py:28: in update

    NamedObject._elaborate_stack[-1]._update( blk )

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/dsl/ComponentLevel2.py:532: in _update

    s._cache_func_meta( blk, is_update_ff=False ) # add caching of src/ast

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/dsl/ComponentLevel2.py:111: in _cache_func_meta

    AstHelper.extract_reads_writes_calls( s, func, _ast, _rd, _wr, _fc )

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/dsl/AstHelper.py:213: in extract_reads_writes_calls

    visitor.enter( stmt, read, write, calls )

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/dsl/AstHelper.py:125: in enter

    self.visit( node )

/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ast.py:407: in visit

    return visitor(node)

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/dsl/AstHelper.py:129: in visit_Assign

    self.visit( x )

/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ast.py:407: in visit

    return visitor(node)

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/dsl/AstHelper.py:152: in visit_Subscript

    obj_name, nodelist = self._get_full_name( node )

../../../../pymtl3/lib/python3.9/site-packages/pymtl3/dsl/AstHelper.py:97: in _get_full_name

    assert isinstance( node, ast.Str ) # filter out line_trace

E   AssertionError: assert False

E    +  where False = isinstance(<ast.Subscript object at 0x10abbe7f0>, <class 'ast.Str'>)

E    +    where <class 'ast.Str'> = ast.Str

================================================================ 1 failed in 0.63s =================================================================


Peitian Pan

unread,
Nov 21, 2020, 2:34:13 PM11/21/20
to pymtl-users
Please note that PyMTL3 currently does not officially support Python > 3.7. Since this assertion fires while parsing the AST my bet is that Python 3.9 introduces syntax changes that we haven't accounted for yet.
Reply all
Reply to author
Forward
0 new messages