#19398: django.utils._os.safe_join should return a native string ---------------------------------+-------------------------------------- Reporter: aaugustin | Owner: nobody Type: Bug | Status: new Component: Python 2 | Version: 1.5-beta-1 Severity: Release blocker | Resolution: Keywords: | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ---------------------------------+--------------------------------------
Comment (by aaugustin): I've created a pull request that: 1) Introduces `path_as_str` and `path_as_text` functions: - They do nothing under Python 3; they're only needed under Python 2; the following only applies to Python 2. - Their primary goal is to make conversions to and from filesystem paths explicit. For instance, if `TEMPLATE_DIRS` contains an unicode string, it must be converted to the filesystem's charset before being used for filesystem-related operations. (If we were strong typing fanatics, we'd have a FileSystemPath type, distinct from the regular string types.) - Currently, they're used at all safe_join and abspathu call sites, to guarantee backwards-compatibility. But the goal is to remove as many uses as possible in the near future (ie. #19357). 2) Drops `_os.abspathu(...)` in favor of the equivalent `path_as_text(os.path.abspath(path_as_str(...))`. 3) Modifies the implementation `_os.safe_join(..., ...)` to be consistent with `os.path.join` typewise, and replaces its current uses by the new equivalent `path_as_text(_os.safe_join(path_as_str(...), path_as_str(...))` 4) Tests that `safe_join` doesn't coerce to unicode any longer. Link: https://github.com/django/django/pull/564 -- Ticket URL: <https://code.djangoproject.com/ticket/19398#comment:2> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.