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

Python 3.14, pathname2url does not add // #3362

Closed
1 task
ToshibaMastr opened this issue Dec 30, 2024 · 1 comment · Fixed by #3364
Closed
1 task

Python 3.14, pathname2url does not add // #3362

ToshibaMastr opened this issue Dec 30, 2024 · 1 comment · Fixed by #3364
Labels
🐛 bug Something isn't working

Comments

@ToshibaMastr
Copy link

Describe the bug

def path_to_url(path: str) -> str:
    """
    Convert a path to a file: URL.  The path will be made absolute and have
    quoted path parts.
    """
    from urllib.request import pathname2url

    path = os.path.normpath(os.path.abspath(path))
    url = parse.urljoin("file:", pathname2url(path))
    return url

In the path_to_url function, parse.urljoin does not add '//", which causes an error

To reproduce

(socketio-3.14) ➜  socketio pdm update
  0:00:01 🔒 Lock successful.
See /home/mastru/.local/state/pdm/log/pdm-install-cja6lb2y.log for detailed debug log.
[RequirementError]: file:/home/mastru/pg/ProjectNoname/socketio: Expected end or semicolon (after name and no valid version specifier)
    file:/home/mastru/pg/ProjectNoname/socketio

Expected Behavior

package updates

Environment Information

➜  socketio pdm info && pdm info --env
PDM version:
  2.22.1
Python Interpreter:
  /home/mastru/pg/ProjectNoname/socketio/.venv/bin/python (3.14)
Project Root:
  /home/mastru/pg/ProjectNoname/socketio
Local Packages:

{
  "implementation_name": "cpython",
  "implementation_version": "3.14.0a3",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.12.4-arch1-1",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT_DYNAMIC Mon, 09 Dec 2024 14:31:57 +0000",
  "python_full_version": "3.14.0",
  "platform_python_implementation": "CPython",
  "python_version": "3.14",
  "sys_platform": "linux"
}

Verbose Command Output

No response

Additional Context

This is only on python 3.14, as it is on python 3.13. "//" is added automatically.

# 3.13
>>> parse.urljoin("file://", pathname2url("/home"))
'file:///home'
# 3.14
>>> parse.urljoin("file:", pathname2url("/home"))
'file:/home

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.
@ToshibaMastr ToshibaMastr added the 🐛 bug Something isn't working label Dec 30, 2024
@monchin
Copy link
Contributor

monchin commented Dec 30, 2024

3.14 is too early, I guess it's better to wait until it releases.

@frostming frostming linked a pull request Dec 31, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants