MCPcopy Index your code
hub / github.com/RustPython/RustPython / _sanity_check

Function _sanity_check

Lib/importlib/_bootstrap.py:1290–1303  ·  view source on GitHub ↗

Verify arguments are "sane".

(name, package, level)

Source from the content-addressed store, hash-verified

1288
1289
1290def _sanity_check(name, package, level):
1291 """Verify arguments are "sane"."""
1292 if not isinstance(name, str):
1293 raise TypeError(f'module name must be str, not {type(name)}')
1294 if level < 0:
1295 raise ValueError('level must be >= 0')
1296 if level > 0:
1297 if not isinstance(package, str):
1298 raise TypeError('__package__ not set to a string')
1299 elif not package:
1300 raise ImportError('attempted relative import with no known parent '
1301 'package')
1302 if not name and level == 0:
1303 raise ValueError('Empty module name')
1304
1305
1306_ERR_MSG_PREFIX = 'No module named '

Callers 1

_gcd_importFunction · 0.70

Calls 1

isinstanceFunction · 0.85

Tested by

no test coverage detected