Page MenuHomePhabricator

Python 2 RuntimeWarning when running a script in a dir without __init__
Closed, DeclinedPublic

Description

When running a script that isnt in scripts, and doesnt have a __init__.py, a RuntimeWarning is emitted during imports on Python 2.

core$ python pwb.py jsonstuff/create.py
WARNING: ./jsonstuff/create.py:1: RuntimeWarning: Parent module 'jsonstuff' not found while handling absolute import
  from pywikibot.data import jsondump

WARNING: ./jsonstuff/create.py:3: RuntimeWarning: Parent module 'jsonstuff' not found while handling absolute import
  import pywikibot

It looks scary, and should be avoided. The script author can avoid it by using absolute_import. Hopefully we can avoid it, or better advise the user on how to remedy it.

Event Timeline

jayvdb renamed this task from RuntimeWarning when running a script in a dir without __init__ to Python 2 RuntimeWarning when running a script in a dir without __init__.Aug 11 2016, 5:29 AM
jayvdb updated the task description. (Show Details)
Xqt triaged this task as Lowest priority.Oct 10 2016, 2:57 PM

user_script_paths may be used to solve that and in addition Python 2 support will be dropped. Closed it after this long time.