Bug 2199

Summary: Python 3 error on test.py and valgrind
Product: ns-3 Reporter: natale.patriciello
Component: test frameworkAssignee: ns-bugs <ns-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: natale.patriciello, tomh
Priority: P5    
Version: pre-release   
Hardware: PC   
OS: Linux   

Description natale.patriciello 2015-10-27 05:37:07 UTC
When using python3, and test.py with valgrind, the following may appear:

Exception in thread Thread-6:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 923, in _bootstrap_inner
    self.run()
  File "./test.py", line 971, in run
    job.cwd, options.valgrind, job.is_pyexample, job.build_path)
  File "./test.py", line 780, in run_job_synchronously
    if valgrind and retval == 0 and "== LEAK SUMMARY:" in stderr_results:
TypeError: a bytes-like object is required, not 'str'

This is because stderr_results, obtained with

  stdout_results, stderr_results = proc.communicate()

has changed type. Before, it was a string (Captured stderr from the child process. A bytes sequence, or a string if run() was called with universal_newlines=True. None if stderr was not captured, from [1]). So, a quick fix is to decode the bytes into a string:


  stdout_results, stderr_results = proc.communicate()
  elapsed_time = time.time() - start_time

  retval = proc.returncode
  stdout_results = stdout_results.decode("utf-8")
  stderr_results = stderr_results.decode("utf-8")

  ...

And then enjoy test.py -g without errors.
Have a nice day!


[1] https://docs.python.org/3/library/subprocess.html#using-the-subprocess-module
Comment 1 Tom Henderson 2015-10-27 15:53:01 UTC
fixed in changeset 11731:7890c40df838