Repository: pytorch
Issue: jit script fails with `AttributeError: 'str' object has no attribute 'lineno'`
Labels: oncall: jit,triaged

## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->

## To Reproduce

minimum failing code:

```python
import torch
from torch import jit
from torch import nn

class Bar(nn.Module):
  def __init__(self, a):
    super(Bar, self).__init__()
    self.a = a

  @torch.no_grad()
  def forward(self, x):
    return x


if __name__ == '__main__':
  a = Bar(1)
  jit.script(a)
```

Run the code above in **Python 2**.

The error message is

```console
File "script_str_error.py", line 20, in <module>
    jit.script(a)
  File "/Users/zaf/Git/pytorch2/torch/jit/__init__.py", line 1239, in script
    return torch.jit.torch.jit._recursive.recursive_script(obj)
  File "/Users/zaf/Git/pytorch2/torch/jit/_recursive.py", line 508, in recursive_script
    return create_script_module(nn_module, infer_methods_to_compile(nn_module))
  File "/Users/zaf/Git/pytorch2/torch/jit/_recursive.py", line 491, in infer_methods_to_compile
    stubs.append(make_stub_from_method(nn_module, method))
  File "/Users/zaf/Git/pytorch2/torch/jit/_recursive.py", line 41, in make_stub_from_method
    return make_stub(func)
  File "/Users/zaf/Git/pytorch2/torch/jit/_recursive.py", line 34, in make_stub
    ast = torch.jit.get_jit_def(func, self_name="RecursiveScriptModule")
  File "/Users/zaf/Git/pytorch2/torch/jit/frontend.py", line 169, in get_jit_def
    return build_def(ctx, py_ast.body[0], type_line, self_name)
  File "/Users/zaf/Git/pytorch2/torch/jit/frontend.py", line 199, in build_def
    param_list = build_param_list(ctx, py_def.args, self_name)
  File "/Users/zaf/Git/pytorch2/torch/jit/frontend.py", line 220, in build_param_list
    ctx_range = ctx.make_range(expr.lineno, expr.col_offset - 1, expr.col_offset + len(expr.arg))
AttributeError: 'str' object has no attribute 'lineno'
```

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->
This code works in **Python 3**, and I was expecting it to behave similarly in 2.

## Environment

Please copy and paste the output from our
[environment collection script](https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py)
(or fill out the checklist below manually).

Collecting environment information...
PyTorch version: 1.4.0a0+a5ac7f6
Is debug build: No
CUDA used to build PyTorch: None

OS: Mac OSX 10.15
GCC version: Could not collect
CMake version: version 3.14.4

Python version: 2.7
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip] numpy==1.16.5
[pip] torch==1.4.0a0+a5ac7f6
[conda] Could not collect


 - PyTorch Version (e.g., 1.0): **master build**
 - OS (e.g., Linux): **OSx 10.15**
 - How you installed PyTorch (`conda`, `pip`, source): **source**
 - Build command you used (if compiling from source): **`python setup.py develop`**
 - Python version: **2.7**
 - CUDA/cuDNN version: **None**
 - GPU models and configuration: **None**
 - Any other relevant information:

## Additional context




cc @suo