Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add a new object - RuntimeError: 'path' must be None or a list, not <class '_frozen_importlib_external._NamespacePath'> #16

Open
tunarob opened this issue May 8, 2017 · 3 comments

Comments

@tunarob
Copy link

tunarob commented May 8, 2017

I get this:

  File "/app/apps/posts/forms.py", line 19, in save
    instance.save()
  File "/usr/local/lib/python3.5/site-packages/django/db/models/base.py", line 806, in save
    force_update=force_update, update_fields=update_fields)
  File "/usr/local/lib/python3.5/site-packages/django/db/models/base.py", line 831, in save_base
    update_fields=update_fields,
  File "/usr/local/lib/python3.5/site-packages/django/dispatch/dispatcher.py", line 193, in send
    for receiver in self._live_receivers(sender)
  File "/usr/local/lib/python3.5/site-packages/django/dispatch/dispatcher.py", line 193, in <listcomp>
    for receiver in self._live_receivers(sender)
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/fields.py", line 136, in process_bbcodes
    parser = get_parser()
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/bbcode/__init__.py", line 23, in get_parser
    loader.load_parser()
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/bbcode/__init__.py", line 42, in load_parser
    self.init_bbcode_placeholders()
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/bbcode/__init__.py", line 75, in init_bbcode_placeholders
    placeholders = placeholder_pool.get_placeholders()
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/placeholder_pool.py", line 73, in get_placeholders
    self.discover_placeholders()
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/placeholder_pool.py", line 33, in discover_placeholders
    load('bbcode_placeholders')
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/core/loading.py", line 37, in load
    get_module(app, modname)
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/core/loading.py", line 23, in get_module
    imp.find_module(modname, app_path)
  File "/usr/local/lib/python3.5/imp.py", line 270, in find_module
    "not {}".format(type(path)))
RuntimeError: 'path' must be None or a list, not <class '_frozen_importlib_external._NamespacePath'>

I use Python 3.5 and Django 1.11. I followed the docs (nothing complicated):

content = BBCodeTextField(verbose_name='content')

But in my tests when I send a POST:

post_data = {
    'title': 'Test title with ł',
    'categories': [category.pk for category in categories],
    'tags': tags,
    'content': 'Hello world!',
}

response = self.client.post(self.url, post_data)

I get above error. The only custom thing is in my form:

def save(self, commit=True):
    instance = super().save(commit=False)
    instance.slug = slugify(instance.title, only_ascii=True)
    instance.status = Post.STATUS_CHOICES[0][0]

    if commit:
        instance.save()
        self.save_m2m()
    return instance

Any idea what that can be?

@tunarob
Copy link
Author

tunarob commented May 8, 2017

I found it fails on this (in ipdb):

ipdb> from precise_bbcode.bbcode import get_parser
ipdb> parser = get_parser()
*** RuntimeError: 'path' must be None or a list, not <class '_frozen_importlib_external._NamespacePath'>

@tunarob
Copy link
Author

tunarob commented May 8, 2017

I'm able to reproduce that error. The reason why it fails is that 1 of my apps didn't have __init__.py file but was included in INSTALLED_APPS.

What is the desired behaviour? Should That skip (try: except:) invalid apps or fail?
I could create a PR with the "skipping" part if this is how it should be.

@ellmetha
Copy link
Owner

ellmetha commented May 11, 2017

Well, if I understand correctly, the main problem seems to be that one of your apps didn't have an __init__.py file. But it should have one, right? In that case, I don't see why there should be a special case implemented in django-precise-bbcode. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants