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

py4j/java_gateway.py: DeprecationWarning: invalid escape sequence \* #377

Closed
AbdealiLoKo opened this issue Aug 4, 2019 · 1 comment
Closed
Assignees
Milestone

Comments

@AbdealiLoKo
Copy link
Contributor

AbdealiLoKo commented Aug 4, 2019

When I run pytest on some Spark (2.4.3) application, I get a warning from py4j which says:

/usr/local/hadoop/spark/python/lib/py4j-0.10.7-src.zip/py4j/java_gateway.py:2020
  /usr/local/hadoop/spark/python/lib/py4j-0.10.7-src.zip/py4j/java_gateway.py:2020: DeprecationWarning:

  invalid escape sequence \*

On digging into the zip file, i found this is happening due to the \* in the docstring at:
https://github.com/bartdag/py4j/blob/7d931a9c41d122ea9cfdc76a322f6706c45eedda/py4j-python/src/py4j/java_gateway.py#L2062

This happens with Python 3.6 as mentioned in the deprecated behavior release notes:
https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior

A backslash-character pair that is not a valid escape sequence now generates a DeprecationWarning. Although this will eventually become a SyntaxError, that will not be for several Python releases. (Contributed by Emanuel Barry in bpo-27364.)

While not critical at the moment, it would be good to avoid this so that warnings don't pop up. And this will later become a SyntaxError.

A quick google search shows there were similar issues in other libraries:
pallets/flask#3056

@bartdag
Copy link
Collaborator

bartdag commented Aug 4, 2019

Thanks for this bug report!

I was surprised at first, but it makes sense that the interpreter is actually interpreting these strings (available through doc). I also learned that there is such a thing as a raw docstring (r"""..."""), which may be easier on the eye in this case.

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

Successfully merging a pull request may close this issue.

2 participants