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.13 compatibility #470

Open
offa opened this issue Jan 16, 2025 · 1 comment
Open

Python 3.13 compatibility #470

offa opened this issue Jan 16, 2025 · 1 comment
Labels
Help Wanted We will be glad if somebody proposes a solution via PR

Comments

@offa
Copy link
Contributor

offa commented Jan 16, 2025

With #463 the library works on Python 3.12 (#430), but not on Python 3.13 yet:

AttributeError: module 'pathlib' has no attribute 'posixpath'. Did you mean: 'PosixPath'?

Reported location

Tested using master at 46728f6.

@allburov allburov added the Help Wanted We will be glad if somebody proposes a solution via PR label Jan 17, 2025
@offa
Copy link
Contributor Author

offa commented Jan 31, 2025

While the posixpath issue is fixed very easily, the issues that follow are more complicated.

--- a/artifactory.py
+++ b/artifactory.py
@@ -33,6 +33,7 @@ import json
 import os
 import pathlib
 import platform
+import posixpath
 import re
 import urllib.parse
 from itertools import chain
@@ -444,7 +445,7 @@ class _ArtifactoryFlavour(object if IS_PYTHON_3_12_OR_NEWER else pathlib._Flavou
     sep = "/"
     altsep = "/"
     has_drv = True
-    pathmod = pathlib.posixpath
+    pathmod = posixpath
     is_supported = True
 
     def _get_base_url(self, url):

(The underlying issue here is the changed pathlib API, pathmod seems not to have any effect on the actual issue as long as it's valid code)

Using this minimal example:

from artifactory import ArtifactoryPath

path = ArtifactoryPath("https://mysite/artifactory")
print(path)

I get correct results on Python <= 3.12:

https://mysite/artifactory

but a broken path on Python 3.13:

https:/mysite/artifactory
     ^^^
  Note the missing '/'

This causes invalid URLs on subsequent usages, which eventually end in a type error ("TypeError: must be str, not NoneType"; see below)

Running this projects tests on Python 3.13 confirms broken paths and/or resulting errors:

[…]
   File "/home/runner/work/artifactory/artifactory/artifactory.py", line 707, in rest_get
    url = quote_url(url)
  File "/home/runner/work/artifactory/artifactory/artifactory.py", line 424, in quote_url
    quoted_path = requests.utils.quote(url.partition(parsed_url.host)[2])
                                       ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
TypeError: must be str, not NoneType


[…]
 AssertionError: 'http:/b/artifactory/reponame/path.txt' != 'http://b/artifactory/reponame/path.txt'
- http:/b/artifactory/reponame/path.txt
+ http://b/artifactory/reponame/path.txt
?      +

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted We will be glad if somebody proposes a solution via PR
Development

No branches or pull requests

2 participants