mciepluc / cocotb-coverage

Functional Coverage and Constrained Randomization Extensions for Cocotb
BSD 2-Clause "Simplified" License
104 stars 16 forks source link

Failed to import module test_fifo: 'return' with argument inside generator (test_fifo.py line 133) #6

Closed dywcheng closed 5 years ago

dywcheng commented 5 years ago

Hi,

I downloaded the lib and ran make SIM=icarus -d because it failed import test_fifo.py due to Syntax error. I didn't do any modification. Here is the long version of the message. Please help. Thanks.

0.00ns INFO     cocotb.regression                         regression.py:133  in initialise                      MODULE variable was "test_fifo"
0.00ns INFO     cocotb.regression                         regression.py:134  in initialise                      Traceback: 
0.00ns INFO     cocotb.regression                         regression.py:135  in initialise                      Traceback (most recent call last):
                                                                                                                  File "/home/dywcheng/nonShareVM/cocotb/cocotb/regression.py", line 130, in initialise
                                                                                                                    module = _my_import(module_name)
                                                                                                                  File "/home/dywcheng/nonShareVM/cocotb/cocotb/regression.py", line 65, in _my_import
                                                                                                                    mod = __import__(name)
                                                                                                                SyntaxError: 'return' with argument inside generator (test_fifo.py, line 133)
mciepluc commented 5 years ago

@dywcheng Are you calling make from cocotb-coverage/examples/fifo/tests dircetory? Have you updated your path to COCOTB in the Makefile? Therefore, is your PYTHONPATH correct?

dywcheng commented 5 years ago

Answers are all YES. Please see below.

dywcheng@ubuntu:~/nonShareVM/cocotb/cocotb_coverage/examples/fifo/tests$ !ma make SIM=icarus make results.xml make[1]: Entering directory '/home/dywcheng/nonShareVM/cocotb/cocotb_coverage/examples/fifo/tests' PYTHONPATH=/home/dywcheng/nonShareVM/cocotb/build/libs/x86_64:/home/dywcheng/nonShareVM/cocotb:/home/dywcheng/nonShareVM/cocotb/cocotb_coverage/examples/fifo/tests:/home/dywcheng/nonShareVM/cocotb/cocotb_coverage/examples/fifo/tests/../../..: LD_LIBRARY_PATH=/home/dywcheng/nonShareVM/cocotb/build/libs/x86_64::/usr/lib:/usr/lib:/usr/lib:/usr/lib MODULE=test_fifo \ TESTCASE= TOPLEVEL=fifo_mem TOPLEVEL_LANG=verilog \ /usr/bin/vvp -M /home/dywcheng/nonShareVM/cocotb/build/libs/x86_64 -m gpivpi sim_build/sim.vvp -.--ns INFO cocotb.gpi gpi_embed.c:111 in embed_init_python Did not detect Python virtual environment. Using system-wide Python interpreter. -.--ns INFO cocotb.gpi GpiCommon.cpp:91 in gpi_print_registered_impl VPI registered 0.00ns INFO cocotb.gpi gpi_embed.c:278 in embed_sim_init Running on Icarus Verilog version 0.9.7 0.00ns INFO cocotb.gpi gpi_embed.c:279 in embed_sim_init Python interpreter initialised and cocotb loaded! 0.00ns INFO cocotb init.py:132 in _initialise_testbench Running tests with Cocotb v1.0.1 from /home/dywcheng/nonShareVM/cocotb 0.00ns INFO cocotb init.py:148 in _initialise_testbench Seeding Python random module with 1547371833 0.00ns CRITICAL cocotb.regression regression.py:132 in initialise Failed to import module test_fifo: 'return' with argument inside generator (test_fifo.py, line 133) 0.00ns INFO cocotb.regression regression.py:133 in initialise MODULE variable was "test_fifo" 0.00ns INFO cocotb.regression regression.py:134 in initialise Traceback: 0.00ns INFO cocotb.regression regression.py:135 in initialise Traceback (most recent call last):

                                      File

"/home/dywcheng/nonShareVM/cocotb/cocotb/regression.py", line 130, in initialise

                                        module = _my_import(module_name)

                                      File

"/home/dywcheng/nonShareVM/cocotb/cocotb/regression.py", line 65, in _my_import

                                        mod = __import__(name)

                                    SyntaxError: 'return' with argument

inside generator (test_fifo.py, line 133)

Traceback (most recent call last): File "/home/dywcheng/nonShareVM/cocotb/cocotb/init.py", line 168, in _initialise_testbench regression.initialise() File "/home/dywcheng/nonShareVM/cocotb/cocotb/regression.py", line 130, in initialise module = _my_import(module_name) File "/home/dywcheng/nonShareVM/cocotb/cocotb/regression.py", line 65, in _my_import mod = import(name) File "/home/dywcheng/nonShareVM/cocotb/cocotb_coverage/examples/fifo/tests/test_fifo.py", line 133 return data, success SyntaxError: 'return' with argument inside generator Cocotb initialisation failed - exiting 0.00ns ERROR cocotb.scheduler init.py:191 in _sim_event Failing test at simulator request before test run completion: Simulator shutdown prematurely make[1]: Leaving directory '/home/dywcheng/nonShareVM/cocotb/cocotb_coverage/examples/fifo/tests'

Are you calling make from cocotb-coverage/examples/fifo/tests dircetory?

Have you updated your path to COCOTB in the Makefile? Therefore, is your PYTHONPATH correct?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mciepluc/cocotb-coverage/issues/6#issuecomment-453809391, or mute the thread https://github.com/notifications/unsubscribe-auth/AjkI-FOPFU5xF8Sya6GnaIzc47rhtJt8ks5vCuSUgaJpZM4Z87kS .

mciepluc commented 5 years ago

Looks like there is an issue with using return in function process_data. As it is a generator (coroutine) it shoud return value by yield. According to explanation current implementation is acceptable with Python 3.3 and above. I will take a look and possibly fix it.

@dywcheng please note you need to use Python 3 anyway for this package, so if you switch to the recent Python distribution, this issue should not be present.

dywcheng commented 5 years ago

Hi Marek,

Could you please let me know how to set that in the Makefile because I have both Python versions? However, I read online while looking for solution. It's not recommended to alias python to python3 because Ubuntu needs Python 2.x.

Thank you,

David Cheng

On Sun, Jan 13, 2019, 1:48 AM Marek Cieplucha <notifications@github.com wrote:

Looks like there is an issue with using return in function process_data. As it is a generator (coroutine) it shoud return value by yield. According to explanation https://stackoverflow.com/questions/16780002/return-in-generator-together-with-yield-in-python-3-3 current implementation is acceptable with Python 3.3 and above. I will take a look and possibly fix it.

@dywcheng https://github.com/dywcheng please note you need to use Python 3 anyway for this package, so if you switch to the recent Python distribution, this issue should not be present.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mciepluc/cocotb-coverage/issues/6#issuecomment-453815814, or mute the thread https://github.com/notifications/unsubscribe-auth/AjkI-EeDUZsJ0xOi6UqK7TEx4koxK58Gks5vCwDXgaJpZM4Z87kS .

mciepluc commented 5 years ago

@dywcheng it depends on your system setup. You should play with your environment variables (PATH, PYTHONPATH, PYTHONHOME) to make sure cocotb runs on Python 3. You can try setting PYTHON_BIN=python3. If you need further help on that you can ask within cocotb project.

mciepluc commented 5 years ago

I don't think this will be an issue for anyone, as using Python version below 3.3 is unlikely for this package. Therefore this bug is not going to be fixed.

jahagirdar commented 5 years ago

Came to this thread because I had the same problem. Leaving the solution here in case I forget it and come again next year :)

python3.6 -m venv `pwd`
source /bin/activate
make