Skip to content

Commit 2cea534

Browse files
Python 3.14 compatibility
Between Python 3.13 and Python 3.14, glob._Globber was renamed to glob._GlobberBase. Guard class choice with Python 3.14 version check.
1 parent e0d30c3 commit 2cea534

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
17+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
1818

1919
steps:
2020
- uses: actions/checkout@v4

artifactory.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
from dohq_artifactory.compat import IS_PYTHON_3_10_OR_NEWER
5858
from dohq_artifactory.compat import IS_PYTHON_3_12_OR_NEWER
5959
from dohq_artifactory.compat import IS_PYTHON_3_13_OR_NEWER
60+
from dohq_artifactory.compat import IS_PYTHON_3_14_OR_NEWER
6061
from dohq_artifactory.exception import ArtifactoryException
6162
from dohq_artifactory.exception import raise_for_status
6263
from dohq_artifactory.logger import logger
@@ -1499,28 +1500,28 @@ class ArtifactoryOpensourceAccessor(_ArtifactoryAccessor):
14991500

15001501

15011502
# In Python 3.13, pathlib now reuses code from the glob package in order to implement
1502-
# the Path.glob() method. There are two related classes in the glob package, _Globber
1503+
# the Path.glob() method. There are two related classes in the glob package, _GlobberBase
15031504
# and _StringGlobber, where the former will delegate operations to the Path object while
15041505
# the latter directly calls os.path functions, performing actual file system calls. The
15051506
# private abstract base class of PurePath, PurePathBase, sets the _globber class
1506-
# attribute to _Globber, while PurePath overrides it to be _StringGlobber.
1507+
# attribute to _GlobberBase, while PurePath overrides it to be _StringGlobber.
15071508
#
1508-
# We create a custom subclass that explicitly subclasses _Globber and not
1509+
# We create a custom subclass that explicitly subclasses _GlobberBase and not
15091510
# _StringGlobber, since we want the version that delegates file system operations to the
15101511
# Path objects.
15111512
#
1512-
# In addition, we override _Globber.recursive_selector() with a copy of the original
1513+
# In addition, we override _GlobberBase.recursive_selector() with a copy of the original
15131514
# code but with one modification. Inside the definition of the nested select_recursive()
15141515
# function, we # add 1 to the original value of match_pos. The reason for this is that
15151516
# the add_slash() method will not actually add a slash when the path object is an
15161517
# instance of a Path subclass, since it will normally get normalized away. The match
15171518
# position therefore needs to be incremented by 1 in order to account for the actual
15181519
# slash character that appears when inspecting children of the current directory. This
1519-
# isn't an issue in the actual use of _Globber in Python, since it converts all paths to
1520+
# isn't an issue in the actual use of _GlobberBase in Python, since it converts all paths to
15201521
# strings, and the add_slash() will literally append a slash character to the string
15211522
# path. See the original code in
1522-
# https://github.com/python/cpython/blob/v3.13.2/Lib/glob.py#L448-L510
1523-
class _ArtifactoryGlobber(glob._Globber if IS_PYTHON_3_13_OR_NEWER else object):
1523+
# https://github.com/python/cpython/blob/v3.14.0/Lib/glob.py#L445-L505
1524+
class _ArtifactoryGlobber(glob._GlobberBase if IS_PYTHON_3_14_OR_NEWER else glob._Globber if IS_PYTHON_3_13_OR_NEWER else object):
15241525
def recursive_selector(self, part, parts):
15251526
"""Returns a function that selects a given path and all its children,
15261527
recursively, filtering by pattern.

dohq_artifactory/compat.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
# parts of the code once python3.12 is no longer supported. This constant helps
1414
# identifying those.
1515
IS_PYTHON_3_13_OR_NEWER = sys.version_info >= (3, 13)
16+
# glob._Globber was renamed to glob._GlobberBase in 3.14
17+
# https://github.com/python/cpython/commit/242c7498e5a889b47847fb6f0f133ce461fa7e24
18+
IS_PYTHON_3_14_OR_NEWER = sys.version_info >= (3, 14)

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"Programming Language :: Python :: 3.11",
4949
"Programming Language :: Python :: 3.12",
5050
"Programming Language :: Python :: 3.13",
51+
"Programming Language :: Python :: 3.14",
5152
"Topic :: Software Development :: Libraries",
5253
"Topic :: System :: Filesystems",
5354
],

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ envlist =
66
py311
77
py312
88
py313
9+
py314
910
pre-commit
1011

1112
[testenv]

0 commit comments

Comments
 (0)