Skip to content

Python 3.6 invalid escape sequence deprecation fixes #607

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

Merged
merged 1 commit into from
Apr 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, obje
# They must be compatible to the LockFile interface.
# A suitable alternative would be the BlockingLockFile
t_lock = LockFile
re_comment = re.compile('^\s*[#;]')
re_comment = re.compile(r'^\s*[#;]')

#} END configuration

Expand Down
4 changes: 2 additions & 2 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class FetchInfo(object):
NEW_TAG, NEW_HEAD, HEAD_UPTODATE, TAG_UPDATE, REJECTED, FORCED_UPDATE, \
FAST_FORWARD, ERROR = [1 << x for x in range(8)]

re_fetch_result = re.compile('^\s*(.) (\[?[\w\s\.$@]+\]?)\s+(.+) -> ([^\s]+)( \(.*\)?$)?')
re_fetch_result = re.compile(r'^\s*(.) (\[?[\w\s\.$@]+\]?)\s+(.+) -> ([^\s]+)( \(.*\)?$)?')

_flag_map = {'!': ERROR,
'+': FORCED_UPDATE,
Expand Down Expand Up @@ -391,7 +391,7 @@ def __init__(self, repo, name):

def __getattr__(self, attr):
"""Allows to call this instance like
remote.special( \*args, \*\*kwargs) to call git-remote special self.name"""
remote.special( \\*args, \\*\\*kwargs) to call git-remote special self.name"""
Copy link

@isaacsanders isaacsanders Mar 23, 2017

Choose a reason for hiding this comment

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

Why not use a raw string here? (I am fairly new to Python, so this is a question seeking a real answer if there is an answer, not a passive aggressive question)

It seems like a raw string would lend itself well to docstrings, even in the case below, where (I believe) there are embedded unicode code points, since it may be easier to copy and paste.

Choose a reason for hiding this comment

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

Typically you don't see docstrings being raw strings.

Choose a reason for hiding this comment

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

Does it negatively effect their use as docstrings?

Copy link

@isaacsanders isaacsanders Mar 23, 2017

Choose a reason for hiding this comment

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

It seems like you might want to have the docstring be WYSIWYG, and the raw string appears to be meant for that, to me... But like I said, I am fairly new, so if I am missing something, I am happy to listen.

Choose a reason for hiding this comment

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

I don't have any say in this repo so I don't mind either way. Just a preference and for homogeneity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, FWIW and all that, I don't know why the asterisks in this particular docstring are backslash escaped in the first place.

if attr == "_config_reader":
return super(Remote, self).__getattr__(attr)

Expand Down
2 changes: 1 addition & 1 deletion git/test/lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def git_daemon_launched(base_path, ip, port):
and setting the environment variable GIT_PYTHON_TEST_GIT_DAEMON_PORT to <port>
""")
if is_win:
msg += textwrap.dedent("""
msg += textwrap.dedent(r"""

On Windows,
the `git-daemon.exe` must be in PATH.
Expand Down
2 changes: 1 addition & 1 deletion git/test/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_it_transforms_kwargs_into_git_command_arguments(self):
self.assertEqual(set(['-s', '-t']), set(res))

def test_it_executes_git_to_shell_and_returns_result(self):
assert_match('^git version [\d\.]{2}.*$', self.git.execute(["git", "version"]))
assert_match(r'^git version [\d\.]{2}.*$', self.git.execute(["git", "version"]))

def test_it_accepts_stdin(self):
filename = fixture_path("cat_file_blob")
Expand Down
2 changes: 1 addition & 1 deletion git/test/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def _count_existing(self, repo, files):
# END num existing helper

@skipIf(HIDE_WINDOWS_KNOWN_ERRORS and Git.is_cygwin(),
"""FIXME: File "C:\projects\gitpython\git\test\test_index.py", line 642, in test_index_mutation
"""FIXME: File "C:\\projects\\gitpython\\git\\test\\test_index.py", line 642, in test_index_mutation
self.assertEqual(fd.read(), link_target)
AssertionError: '!<symlink>\xff\xfe/\x00e\x00t\x00c\x00/\x00t\x00h\x00a\x00t\x00\x00\x00'
!= '/etc/that'
Expand Down
2 changes: 1 addition & 1 deletion git/test/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def test_blame_complex_revision(self, git):
self.assertEqual(len(res[0][1]), 83, "Unexpected amount of parsed blame lines")

@skipIf(HIDE_WINDOWS_KNOWN_ERRORS and Git.is_cygwin(),
"""FIXME: File "C:\projects\gitpython\git\cmd.py", line 671, in execute
"""FIXME: File "C:\\projects\\gitpython\\git\\cmd.py", line 671, in execute
raise GitCommandError(command, status, stderr_value, stdout_value)
GitCommandError: Cmd('git') failed due to: exit code(128)
cmdline: git add 1__��ava verb��ten 1_test _myfile 1_test_other_file
Expand Down
6 changes: 3 additions & 3 deletions git/test/test_submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,10 @@ def test_base_bare(self, rwrepo):
self._do_base_tests(rwrepo)

@skipIf(HIDE_WINDOWS_KNOWN_ERRORS and sys.version_info[:2] == (3, 5), """
File "C:\projects\gitpython\git\cmd.py", line 559, in execute
File "C:\\projects\\gitpython\\git\\cmd.py", line 559, in execute
raise GitCommandNotFound(command, err)
git.exc.GitCommandNotFound: Cmd('git') not found due to: OSError('[WinError 6] The handle is invalid')
cmdline: git clone -n --shared -v C:\projects\gitpython\.git Users\appveyor\AppData\Local\Temp\1\tmplyp6kr_rnon_bare_test_root_module""") # noqa E501
cmdline: git clone -n --shared -v C:\\projects\\gitpython\\.git Users\\appveyor\\AppData\\Local\\Temp\\1\\tmplyp6kr_rnon_bare_test_root_module""") # noqa E501
@with_rw_repo(k_subm_current, bare=False)
def test_root_module(self, rwrepo):
# Can query everything without problems
Expand Down Expand Up @@ -664,7 +664,7 @@ def test_add_empty_repo(self, rwdir):
# end for each checkout mode

@skipIf(HIDE_WINDOWS_KNOWN_ERRORS and Git.is_cygwin(),
"""FIXME: ile "C:\projects\gitpython\git\cmd.py", line 671, in execute
"""FIXME: ile "C:\\projects\\gitpython\\git\\cmd.py", line 671, in execute
raise GitCommandError(command, status, stderr_value, stdout_value)
GitCommandError: Cmd('git') failed due to: exit code(128)
cmdline: git add 1__Xava verbXXten 1_test _myfile 1_test_other_file 1_XXava-----verbXXten
Expand Down
4 changes: 2 additions & 2 deletions git/test/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class TestTree(TestBase):

@skipIf(HIDE_WINDOWS_KNOWN_ERRORS and sys.version_info[:2] == (3, 5), """
File "C:\projects\gitpython\git\cmd.py", line 559, in execute
File "C:\\projects\\gitpython\\git\\cmd.py", line 559, in execute
raise GitCommandNotFound(command, err)
git.exc.GitCommandNotFound: Cmd('git') not found due to: OSError('[WinError 6] The handle is invalid')
cmdline: git cat-file --batch-check""")
Expand Down Expand Up @@ -57,7 +57,7 @@ def test_serializable(self):
# END for each item in tree

@skipIf(HIDE_WINDOWS_KNOWN_ERRORS and sys.version_info[:2] == (3, 5), """
File "C:\projects\gitpython\git\cmd.py", line 559, in execute
File "C:\\projects\\gitpython\\git\\cmd.py", line 559, in execute
raise GitCommandNotFound(command, err)
git.exc.GitCommandNotFound: Cmd('git') not found due to: OSError('[WinError 6] The handle is invalid')
cmdline: git cat-file --batch-check""")
Expand Down