Skip to content

Commit

Permalink
Handle changed ntpath.isabs behaviour in Python 3.13 (#110)
Browse files Browse the repository at this point in the history
ntpath.isabs no longer considers paths that start with "/" to
be absolute. This is correct behaviour on Windows but causes us
problems, because our `PathConstants` use paths that start with
/ and expect these to always be considered absolute. To deal
with this, let's add an extra slash to the `PathConstants`;
paths starting `//` are considered absolute by both ntpath and
posixpath.

Signed-off-by: Adam Williamson <[email protected]>
  • Loading branch information
AdamWill committed Jun 13, 2024
1 parent 3d3c092 commit 701182c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/catkin_lint/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ class PathClass(object):


class PathConstants(object):
PACKAGE_SOURCE = "/%s" % generate_random_id()
PACKAGE_BINARY = "/%s" % generate_random_id()
CATKIN_DEVEL = "/%s" % generate_random_id()
CATKIN_INSTALL = "/%s" % generate_random_id()
DISCOVERED_PATH = "/%s" % generate_random_id()
PACKAGE_SOURCE = "//%s" % generate_random_id()
PACKAGE_BINARY = "//%s" % generate_random_id()
CATKIN_DEVEL = "//%s" % generate_random_id()
CATKIN_INSTALL = "//%s" % generate_random_id()
DISCOVERED_PATH = "//%s" % generate_random_id()


class LintInfo(object):
Expand Down
2 changes: 1 addition & 1 deletion test/test_checks_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ def test_exports(self):
find_package(other_catkin REQUIRED)
catkin_package(
CATKIN_DEPENDS other_catkin
INCLUDE_DIRS /not/in/package
INCLUDE_DIRS //not/in/package
)
""",
checks=cc.exports)
Expand Down
4 changes: 2 additions & 2 deletions test/test_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ def test_package_path(self):
self.assertEqual(info.source_relative_path("subdir/filename"), "subdir/filename")
self.assertEqual(info.source_relative_path("subdir/../filename"), "filename")
self.assertEqual(info.source_relative_path("/filename"), "/filename")
self.assertEqual(info.source_relative_path("../../../../filename"), "/filename")
self.assertEqual(info.source_relative_path("../../../../subdir/filename"), "/subdir/filename")
self.assertEqual(info.source_relative_path("../../../../filename"), "//filename")
self.assertEqual(info.source_relative_path("../../../../subdir/filename"), "//subdir/filename")
info.var = {
"CMAKE_CURRENT_SOURCE_DIR": "%s/subdir" % PathConstants.PACKAGE_SOURCE,
}
Expand Down

0 comments on commit 701182c

Please sign in to comment.