boxed / okrand

Okrand is an internationalization/translation tool for Django
BSD 3-Clause "New" or "Revised" License
10 stars 0 forks source link

Error when clicking "Save" in the "Problems" section #6

Closed etamponi closed 5 days ago

etamponi commented 6 days ago

This is what I get:

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/i18n/?language=it

Django Version: 5.1.1
Python Version: 3.12.3
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django_bootstrap5',
 'django_select2',
 'allauth',
 'allauth.account',
 'iommi',
 'okrand',
 'pwa',
 'handover.apps.HandoverConfig']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'allauth.account.middleware.AccountMiddleware',
 'handover.middleware.TimezoneMiddleware',
 'handover.middleware.current_user_middleware',
 'handover.middleware.current_ward_middleware',
 'handover.middleware.time_travel_middleware',
 'iommi.middleware']

Traceback (most recent call last):
  File "/home/emanuele/django/dev/hh/handover/middleware.py", line 46, in <iommi declaration>
    return get_response(request)

The above exception () was the direct cause of the following exception:
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/iommi/__init__.py", line 107, in __call__
    return render(request, response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/iommi/__init__.py", line 83, in render_part
    raise e from fake
    ^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/iommi/__init__.py", line 71, in render_part
    return part.render_to_response()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/iommi/declarative/dispatch.py", line 10, in dispatch_defaults_wrapper
    return f(*args, **Namespace(defaults, kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/iommi/part.py", line 169, in render_to_response
    dispatch = self.perform_dispatch(**kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/iommi/declarative/dispatch.py", line 10, in dispatch_defaults_wrapper
    return f(*args, **Namespace(defaults, kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/iommi/part.py", line 153, in perform_dispatch
    result = dispatcher(root=self, path=dispatch_target, value=value)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/iommi/endpoint.py", line 123, in perform_post_dispatch
    return target.invoke_callback(target.post_handler, value=value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/iommi/traversable.py", line 251, in invoke_callback
    return callback(**all_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/okrand/views.py", line 194, in save
    f.write(JavaScriptCatalog().get(request).content)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/django/views/i18n.py", line 122, in get
    self.translation = DjangoTranslation(locale, domain=domain, localedirs=paths)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/django/utils/translation/trans_real.py", line 184, in __init__
    self._add_fallback(localedirs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/django/utils/translation/trans_real.py", line 248, in _add_fallback
    default_translation = DjangoTranslation(

  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/django/utils/translation/trans_real.py", line 173, in __init__
    self._add_local_translations()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/django/utils/translation/trans_real.py", line 233, in _add_local_translations
    translation = self._new_gnu_trans(localedir)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emanuele/.cache/pypoetry/virtualenvs/hh-pqyorWhg-py3.12/lib/python3.12/site-packages/django/utils/translation/trans_real.py", line 200, in _new_gnu_trans
    return gettext_module.translation(

  File "/usr/lib/python3.12/gettext.py", line 553, in translation
    t = _translations.setdefault(key, class_(fp))
                                      ^^^^^^^^^^
  File "/usr/lib/python3.12/gettext.py", line 272, in __init__
    self._parse(fp)
    ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/gettext.py", line 353, in _parse
    magic = unpack('<I', buf[:4])[0]
            ^^^^^^^^^^^^^^^^^^^^^

Exception Type: error at /i18n/
Exception Value: unpack requires a buffer of 4 bytes
boxed commented 6 days ago

Hmm.. interesting. Is that maybe a case of #4 first happening and then this crashes as a consequence?

boxed commented 5 days ago

Released 1.1.3 that I believe fixes this.

Thanks for the excellent issues!