Skip to content

Use raw string for docstring that contains a backslash#815

Merged
cgrindel merged 1 commit intobazelbuild:mainfrom
alexbozhenko:patch-1
Feb 1, 2024
Merged

Use raw string for docstring that contains a backslash#815
cgrindel merged 1 commit intobazelbuild:mainfrom
alexbozhenko:patch-1

Conversation

@alexbozhenko
Copy link
Contributor

Python 3.12 started to complain about invalid escape sequences. https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes

One supposed to use r""" when dostrings contains backslashes """ https://stackoverflow.com/a/33734332

Python 3.12 started to complain about invalid escape sequences.
https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes

One supposed to use r""" when dostrings contains backslashes """
https://stackoverflow.com/a/33734332
@alexbozhenko alexbozhenko changed the title Use raw string for docstring that contain backslash Use raw string for docstring that contains a backslash Jan 31, 2024
@cgrindel cgrindel merged commit 1cbb70d into bazelbuild:main Feb 1, 2024
@alexbozhenko
Copy link
Contributor Author

Thanks, Chuck.
Would it be possible to cut a new patch release?

@cgrindel
Copy link
Collaborator

cgrindel commented Feb 4, 2024

@alexbozhenko Unfortunately, I do not have the ability to cut a release. I pinged some folks at Google to try and cut a patch release.

@aiuto
Copy link
Collaborator

aiuto commented Feb 8, 2024

I'll include this in the 0.10.1 release.

@gergelyfabian
Copy link

Very interestingly, even though this is still in rules_pkg 1.1.0, it doesn't work when including rules_pkg as a Bazel dependency with http_archive:

http_archive(
    name = "rules_pkg",
    sha256 = "b7215c636f22c1849f1c3142c72f4b954bb12bb8dcf3cbe229ae6e69cc6479db",
    urls = [
        "https://github.com/bazelbuild/rules_pkg/releases/download/1.1.0/rules_pkg-1.1.0.tar.gz",
    ],
)

The file that bazel unpacks doesn't contain the raw string, but a normal comment string:

$ head -40 ~/.cache/bazel/_bazel_user/7f83a0b1f0940f88aec1f4530f927169/external/rules_pkg/pkg/private/tar/build_tar.py
...
def normpath(path):
  """Normalize a path to the format we need it.
  
  os.path.normpath changes / to \ on windows, but tarfile needs / style paths.

  Args:
    path: (str) path to normalize.
  """
  return os.path.normpath(path).replace(os.path.sep, '/')

If I take the latest rules_pkg source code, and include it with local_repository, it works.

@gergelyfabian
Copy link

gergelyfabian commented Mar 28, 2025

head -40 ~/.cache/bazel/_bazel_user/7f83a0b1f0940f88aec1f4530f927169/external/rules_pkg/pkg/private/tar/build_tar.py

Hmmm, after a bazel clean --expunge the proper sources appeared. Also upgraded from Bazel 7.5.0 to 7.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants