Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#32887 closed Bug (invalid)

v3.2.4 regression - Invalid path type: PurePosixPath

Reported by: Damien Allen Owned by: nobody
Component: Utilities Version: 3.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

After upgrading from v3.2.3 to v3.2.4 the runserver command is now raising a TypeError and exiting. After reviewing the v3.2.4 release notes, I suspect that this is related to changes to template directory traversal since get_template_directories() is in the traceback:

Performing system checks...

Traceback (most recent call last):
  File "manage.py", line 33, in <module>
    main()
  File "manage.py", line 29, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
System check identified no issues (0 silenced).
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 61, in execute
    super().execute(*args, **options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.8/site-packages/channels/management/commands/runserver.py", line 65, in handle
    super().handle(*args, **options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 96, in handle
    self.run(**options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 103, in run
    autoreload.run_with_reloader(self.inner_run, **options)
  File "/usr/local/lib/python3.8/site-packages/django/utils/autoreload.py", line 638, in run_with_reloader
    start_django(reloader, main_func, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/utils/autoreload.py", line 623, in start_django
    reloader.run(django_main_thread)
  File "/usr/local/lib/python3.8/site-packages/django/utils/autoreload.py", line 328, in run
    autoreload_started.send(sender=self)
  File "/usr/local/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 180, in send
    return [
  File "/usr/local/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 181, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))
  File "/usr/local/lib/python3.8/site-packages/django/template/autoreload.py", line 44, in watch_for_template_changes
    for directory in get_template_directories():
  File "/usr/local/lib/python3.8/site-packages/django/template/autoreload.py", line 21, in get_template_directories
    items.update(Path.cwd() / to_path(dir) for dir in backend.engine.dirs)
  File "/usr/local/lib/python3.8/site-packages/django/template/autoreload.py", line 21, in <genexpr>
    items.update(Path.cwd() / to_path(dir) for dir in backend.engine.dirs)
  File "/usr/local/lib/python3.8/site-packages/django/utils/_os.py", line 58, in to_path
    raise TypeError('Invalid path type: %s' % type(value).__name__)
TypeError: Invalid path type: PurePosixPath

Our Django is being run in a docker container (base image python:3.8.6-slim-buster) with WSL2 which could be related to funky path issues.

Reverting to v3.2.3 resolves the issue.

Change History (3)

comment:1 by Mariusz Felisiak, 3 years ago

Resolution: needsinfo
Status: newclosed

Thanks for the report. Is there a reason why you use pathlib.PurePath() (POSIX paths) instead of Path() (cross-OS paths) in your settings? This looks like a misconfiguration to me 🤔

comment:2 by Damien Allen, 3 years ago

We used a cookie-cutter template for our docker setup:

https://github.com/wemake-services/wemake-django-template/blob/master/%7B%7Bcookiecutter.project_name%7D%7D/server/settings/components/__init__.py

I will put in a PR over there, thanks for prompt reply!

comment:3 by Mariusz Felisiak, 3 years ago

Resolution: needsinfoinvalid
Note: See TracTickets for help on using tickets.
Back to Top