anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: serverless/serverless
Issue: FakeLambdaContext have missing log method

# This is a Bug Report 

## Description

There is issue with implementation of FakeLambdaContext,
`FakeLambdaContext` not implementing all of methods from:

https://gist.github.com/gene1wood/c0d37dfcb598fc133a8c

Especially there is missing `context.log`

```python
bash-4.2# sls invoke local -f handle
Traceback (most recent call last):
  File "/usr/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/invoke.py", line 64, in <module>
    result = handler(input['event'], context)
  File "./handler/proxy.py", line 48, in _handle

    ctx.log, ctx.get_remaining_time_in_millis))

AttributeError: 'FakeLambdaContext' object has no attribute 'log'
```


I found it when I tried to run proxy for golang (on python 2.7)

https://github.com/eawsy/aws-lambda-go-shim/blob/a9e5c8b1c1f09a38d3706e552c87ad945299f1f4/src/proxy.py#L45

from: https://github.com/eawsy/aws-lambda-go-shim

I checked official documentation of 
http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html#python-context-object-methods

and looks like method is undocumented hover exist and its used.

I see two options:

- add it to fake context: serverless/serverless#4544 (even if its not officially documented)
- replace it in proxy https://github.com/eawsy/aws-lambda-go-shim/issues/49

I'm looking forward to discuss about it

Changed files:
lib/plugins/aws/invokeLocal/invoke.py

diff --git a/lib/plugins/aws/invokeLocal/invoke.py b/lib/plugins/aws/invokeLocal/invoke.py
index d777950c9..cd10e7910 100755
--- a/lib/plugins/aws/invokeLocal/invoke.py
+++ b/lib/plugins/aws/invokeLocal/invoke.py
@@ -45,6 +45,10 @@ class FakeLambdaContext(object):
     def log_stream_name(self):
         return strftime('%Y/%m/%d') +'/[$' + self.version + ']58419525dade4d17a495dceeeed44708'
 
+    @property
+    def log(self):
+        return sys.stdout.write
+
 logging.basicConfig()
 
 parser = argparse.ArgumentParser(
Repository: serverless/serverless
Issue: After upgrade to 1.33.1 Getting error on local invoke

Upgraded to 1.33.1. 

When I issue this command: `serverless invoke local -f Function_Name -p event.json`

Getting this error:

```
starting...

Traceback (most recent call last):
  File "/usr/local/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/invoke.py", line 77, in <module>

    tty = subprocess.run('tty', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
AttributeError: 'module' object has no attribute 'run'
```

Using python 2.7

Changed files:
lib/plugins/aws/invokeLocal/invoke.py

diff --git a/lib/plugins/aws/invokeLocal/invoke.py b/lib/plugins/aws/invokeLocal/invoke.py
index e0eea5bc0..3884cd05a 100755
--- a/lib/plugins/aws/invokeLocal/invoke.py
+++ b/lib/plugins/aws/invokeLocal/invoke.py
@@ -74,8 +74,11 @@ if __name__ == '__main__':
 
     input = json.load(sys.stdin)
     if sys.platform != 'win32':
-        tty = subprocess.run('tty', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-        if tty.returncode == 0:
+        try:
+            subprocess.check_call('tty', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        except (OSError, subprocess.CalledProcessError):
+            pass
+        else:
             sys.stdin = open('/dev/tty')
 
     context = FakeLambdaContext(**input.get('context', {}))