SeattleTestbed / repy_v2

Seattle Testbed's Repy ("Restricted Python") sandbox, version 2
MIT License
12 stars 50 forks source link

Repy unit tests do not run correctly on Ubuntu 11.10 #24

Closed choksi81 closed 10 years ago

choksi81 commented 10 years ago

On Ubuntu 11.04, x86_64, with Python 2.7.1+ the repyv2api unit tests all pass. They also pass with Python 2.7.2, compiled from source.

On Ubuntu 11.10, x86_64, with Python 2.7.2+, some of the unit tests fail with a message:

Exception exception_hierarchy.RunBuiltinException: RunBuiltinException() in <bound method Popen.__del__ of <subprocess.Popen object at 0x1dbe6d0>> ignored

The problem appears to be related to socket.close(), as commenting out s.close() in the following code allows it to pass the test properly:

#This unit test checks the sendmessage() API call.

#pragma repy
#pragma repy restrictions.twoports

s = listenformessage('127.0.0.1', 12345)

data = "HI"*8

sendmessage('127.0.0.1', 12345, data, '127.0.0.1', 12346)

(rip, rport, mess) = s.getmessage()

s.close()

if mess != data:
  log("Mismatch!",'\n')
aaaaalbert commented 7 years ago

(Note: The original Trac issue description contained more details, replicated below. The fix for the issue was added in 1736e7bfe5f20fa23fda3cb8ef0f43c670690663.)


mkaplan: On examining subprocess.py on Ubuntu 11.10, Popen.__del__ calls getattr.

Adding a traceback:

vm@lapp:~/test$ python repy.py restrictions.twoports ut_repyv2api_sendmessagebasictest.py
  File "repy.py", line 224, in main
  File "/home/vm/test/virtual_namespace.py", line 113, in evaluate
  File "/home/vm/test/safe.py", line 340, in safe_run
  File "ut_repyv2api_sendmessagebasictest.py", line 16, in <module>
  File "/home/vm/test/namespace.py", line 945, in __do_func_call
  File "/home/vm/test/namespace.py", line 1206, in wrapped_function
  File "/home/vm/test/emulcomm.py", line 2229, in close
  File "/home/vm/test/emulcomm.py", line 835, in _cleanup_socket
  File "/usr/lib/python2.7/subprocess.py", line 713, in __del__
  File "/home/vm/test/safe.py", line 198, in fnc
Exception exception_hierarchy.RunBuiltinException: RunBuiltinException() in <bound method Popen.__del__ of <subprocess.Popen object at 0xbf9d10>> ignored

It seems that subprocess requires getatrr to be made available. Adding the following line to safe.py allows the code to run without a problem:

subprocess.getattr = getattr