[issue44412] Add os.path.fileuri() function

2021-06-13 Thread Barney Gale


Change by Barney Gale :


--
keywords: +patch
pull_requests: +25296
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/26708

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44412] Add os.path.fileuri() function

2021-06-13 Thread Barney Gale


New submission from Barney Gale :

Proposal:

- Introduce `os.path.fileuri()` function that produces a 'file://' URI
- Adjust `PurePosixPath.to_uri()` to call `posixpath.fileuri()`
- Adjust `PureWindowsPath.to_uri()` to call `ntpath.fileuri()`
- Adjust `nturl2path.pathname2url()` to call `ntpath.fileuri()`

Rationale:

- pathlib is 95% a wrapper around `os` and `os.path`. It implements
  little itself except the OOP interface. `as_uri()` is one of only a
  tiny handful of pathlib features that have no decent antecedents.
- the existence of these OS-specific features complicates pathlib's
  internals, necessitating the existence of OS-specific '_Flavour'
  classes that greatly complicate work on bpo-24132
- this is a useful feature with lots of stackoverflow posts. It seems
  silly to /require/ users to use pathlib for this, as the rest of their
  codebase may work just fine using traditional path manip.

Further discussion on python-ideas: 
https://discuss.python.org/t/pathlib-and-os-path-feature-parity-and-code-de-duplication/9239

Related: bpo-44403, bpo-44136, bpo-24132

--
components: Library (Lib)
messages: 395756
nosy: barneygale
priority: normal
severity: normal
status: open
title: Add os.path.fileuri() function
type: enhancement
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com