Skip to content

Should resolve ImportError on run time, not compile time #63

@alanjds

Description

@alanjds

google#397 opened by @alanjds on Feb 26

Let be this test code:

import sys
import math

assert sys.modules['math']
assert 'fake_not_existing_module' not in sys.modules

sys.modules['fake_not_existing_module'] = math
assert sys.modules['fake_not_existing_module']

import fake_not_existing_module
assert fake_not_existing_module

It is valid and works on CPython, but Grumpy will raise:

...
  File "/Users/alanjds/src/git/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/imputil.py", line 158, in _resolve_import
    raise util.ImportError(node, 'no such module: {}'.format(modname))
grumpy.compiler.util.ImportError: line 116: no such module: fake_not_existing_module

To me, seems that compile-time import errors should be ignored and be checked/raised only on run time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    importedImported from google/grumpy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions