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

Fix syntax warning over comparison of literals using is. #178

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions memcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class _ConnectionDeadError(Exception):


class Client(threading.local):
"""Object representing a pool of memcache servers.
r"""Object representing a pool of memcache servers.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r"""Object representing a pool of memcache servers.

it's correct to start with the letter "r" ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is valid.

Both string and bytes literals may optionally be prefixed with a letter 'r' or 'R'; such strings are called raw strings and treat backslashes as literal characters. As a result, in string literals, '\U' and '\u' escapes in raw strings are not treated specially. Given that Python 2.x’s raw unicode literals behave differently than Python 3.x’s the 'ur' syntax is not supported.

source: https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to remove that \ in the docstring which should resolve this without the 'r'. I don't believe the \ is needed, it probably was an artifact of a continuation line. Your is -> == is included in a patch I just accepted, so I'm going to commit this change and close this PR as fixed, thank you for the PR!


See L{memcache} for an overview.

Expand Down Expand Up @@ -1300,8 +1300,8 @@ def check_key(self, key, key_extra_len=0):
key = key[1]
if key is None:
raise Client.MemcachedKeyNoneError("Key is None")
if key is '':
if key_extra_len is 0:
if key == '':
if key_extra_len == 0:
raise Client.MemcachedKeyNoneError("Key is empty")

# key is empty but there is some other component to key
Expand Down