Skip to content

retic thinks my module should be an object #34

@bennn

Description

@bennn

Here is a 2-module program:

# module 1, "foo.py"
import math

def f():
  return math.undefined_member(0)
# module 2, "bar.py"
import foo
foo.f()

Running $ retic bar.py prints:

Traceback (most recent call last):
  File "/usr/local/bin/retic", line 6, in <module>
    retic.main()
  File "/home/ben/code/gradual/reticulated/retic/retic.py", line 155, in main
    reticulate(program, prog_args=args.args.split(), flag_sets=args)
  File "/home/ben/code/gradual/reticulated/retic/retic.py", line 104, in reticulate
    utils.handle_runtime_error(exit=True)
  File "/home/ben/code/gradual/reticulated/retic/retic.py", line 102, in reticulate
    _exec(code, __main__.__dict__)
  File "/home/ben/code/gradual/reticulated/retic/exec3/__init__.py", line 2, in _exec
    exec (obj, globs, locs)
  File "foobar.py", line 2, in <module>
    foo.f()
  File "/home/ben/stats/stattest/yolo/foo.py", line 5, in f
    return math.undefined_member(0)
  File "/home/ben/code/gradual/reticulated/retic/runtime.py", line 131, in check_type_object
    rse((type(val), k))
  File "/home/ben/code/gradual/reticulated/retic/runtime.py", line 88, in rse
    raise Exception(x)
Exception: (<class 'module'>, 'undefined_member')

In contrast, running $ python bar.py (for Python 3.4) gives a much clearer error message:

Traceback (most recent call last):
  File "foobar.py", line 2, in <module>
    foo.f()
  File "/home/ben/stats/stattest/yolo/foo.py", line 5, in f
    return math.undefined_member(0)
AttributeError: 'module' object has no attribute 'undefined_member'

The error message from retic seems to be saying that it wants math to be an object. In that case, I see two problems:

  • the original error message is very confusing
  • retic should not expect math to be an object

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions