[IronPython] Spurious warning when executing modules with -m

Dino Viehland dinov at microsoft.com
Sat Aug 22 01:14:30 CEST 2009

runpy is setting __package__ to an empty string.  Looks like CPython doesn't
warn when the string is empty because if I do:

import runpy
x = runpy.run_module('foo', run_name = '__main__', alter_sys=True)

CPython doesn't warn. So the fix is easy enough.

But it's interesting CPython no longer calls runpy.run_module anymore. I
guess it's calling runpy._run_module_as_main as there's a big comment saying
should we make this public.

> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-
> bounces at lists.ironpython.com] On Behalf Of Michael Foord
> Sent: Friday, August 21, 2009 3:40 PM
> To: Discussion of IronPython
> Subject: [IronPython] Spurious warning when executing modules with -m
> Create a Python file called foo.py containing nothing but "import os".
> Execute it with "python -m foo" and "ipy.exe -m foo" (Python 2.6 and
> IronPython 2.6 B2).
> C:\compile\testing>python -m foo
> C:\compile\testing>ipy.exe -m foo
> <string>:1: RuntimeWarning: Parent module '' not found while handling
> absolute import
> Michael
> --
> http://www.ironpythoninaction.com/
> http://www.voidspace.org.uk/blog
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

More information about the Ironpython-users mailing list