gsutil: SyntaxWarning on invalid escape sequences in verdored third-party libraries (boto, pyasn1)
Using Arch Linux, google-cloud-cli from AUR, Python 3.12.3, gsutil emits the following warnings every time it is run:
$ gsutil --version
/opt/google-cloud-cli/platform/gsutil/gslib/vendored/boto/boto/__init__.py:1105: SyntaxWarning: invalid escape sequence '\c'
"""
/opt/google-cloud-cli/platform/gsutil/gslib/vendored/boto/boto/pyami/config.py:98: SyntaxWarning: invalid escape sequence '\s'
match = re.match("^#import[\s\t]*([^\s^\t]*)[\s\t]*$", line)
/opt/google-cloud-cli/platform/gsutil/third_party/pyasn1/pyasn1/type/constraint.py:100: SyntaxWarning: invalid escape sequence '\*'
"""Create a SingleValueConstraint object.
/opt/google-cloud-cli/platform/gsutil/third_party/pyasn1/pyasn1/type/constraint.py:141: SyntaxWarning: invalid escape sequence '\*'
"""Create a ContainedSubtypeConstraint object.
/opt/google-cloud-cli/platform/gsutil/third_party/pyasn1/pyasn1/type/constraint.py:301: SyntaxWarning: invalid escape sequence '\*'
"""Create a PermittedAlphabetConstraint object.
/opt/google-cloud-cli/platform/gsutil/third_party/pyasn1/pyasn1/type/constraint.py:457: SyntaxWarning: invalid escape sequence '\*'
"""Create a ConstraintsIntersection logic operator object.
/opt/google-cloud-cli/platform/gsutil/third_party/pyasn1/pyasn1/type/constraint.py:501: SyntaxWarning: invalid escape sequence '\*'
"""Create a ConstraintsUnion logic operator object.
/opt/google-cloud-cli/platform/gsutil/third_party/pyasn1/pyasn1/type/namedval.py:15: SyntaxWarning: invalid escape sequence '\*'
"""Create named values object.
/opt/google-cloud-cli/platform/gsutil/gslib/vendored/boto/boto/connection.py:672: SyntaxWarning: invalid escape sequence '\w'
'(?:(?P<user>[\w\-\.]+):(?P<pass>.*)@)?'
/opt/google-cloud-cli/platform/gsutil/gslib/vendored/boto/boto/connection.py:673: SyntaxWarning: invalid escape sequence '\w'
'(?P<host>[\w\-\.]+)'
/opt/google-cloud-cli/platform/gsutil/gslib/vendored/boto/boto/connection.py:674: SyntaxWarning: invalid escape sequence '\d'
'(?::(?P<port>\d+))?'
/opt/google-cloud-cli/platform/gsutil/gslib/vendored/boto/boto/connection.py:1121: SyntaxWarning: invalid escape sequence '\.'
'specific endpoint this request was sent to\.'
/opt/google-cloud-cli/platform/gsutil/gslib/vendored/boto/boto/https_connection.py:80: SyntaxWarning: invalid escape sequence '\.'
host_re = host.replace('.', '\.').replace('*', '[^.]*')
gsutil version: 5.27
This is probably happening because in Python 3.12 (2013-10-12, release notes), invalid escape sequences turned from a DeprecationWarning into a SyntaxWarning.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 16
The warnings are resolved in gsutil version 5.32 and above, which supports Python 3.12. Upgrade to this version or later to fix the issue.
It’s been over a year (!) since Python 3.12 was released, and still Google hasn’t tackled this, smh.
Maybe Arch distributors patched it or suppressed the warnings? Anyway, reopening.
Thanks for the feedback! I interpreted the closed issue, along with the positive feedback from @daichunqing and @ttencate, as an indication that this should have already been fixed. The original poster describes the exact incompatibility with Python 3.12.
I added a comment to the issue in the official bug tracker cause the documentation states
@richardburakowski Maybe it used the system Python before, and this was changed to 3.11 shortly after 3.12 was released. This would explain why the errors disappeared for me.
@ttencate - google-cloud-cli from AUR (which is built from the debian package) ships with python 3.11 and is used by gcloud/gsutil by default. You may want to investigate why you’re using the system python 3.12 instead.
For me, I wanted to use numpy with gcloud ssh and was using the system installation
But since the syntax warning I’ve moved to using the shipped 3.11
I’m sorry, but I’m still having these warnings even with 5.30
Python 3.12.5 (main, Aug 7 2024, 00:00:00) [GCC 14.2.1 20240801 (Red Hat 14.2.1-1)] on linux