summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIke Devolder <ike.devolder@gmail.com>2020-03-29 10:27:10 +0200
committerGitHub <noreply@github.com>2020-03-29 10:27:10 +0200
commit694917accd8b2ddeb57fdac8481e9eb5463f9c01 (patch)
treefbd417bbd5f6d3ac0510b393959774138815955d
parent016679bc2edb9300d84e69c44dfa6bd9a13de1eb (diff)
parent4b12452a35d7d7bbf824765015333cab3143fe52 (diff)
downloadvdebug-694917accd8b2ddeb57fdac8481e9eb5463f9c01.zip
Merge pull request #441 from aerostone/fix-win
fix log and breakpoint miss hit on win os
-rw-r--r--python3/vdebug/log.py4
-rw-r--r--python3/vdebug/util.py3
-rw-r--r--tests/test_log.py4
3 files changed, 7 insertions, 4 deletions
diff --git a/python3/vdebug/log.py b/python3/vdebug/log.py
index 5dadea3..7db9a5f 100644
--- a/python3/vdebug/log.py
+++ b/python3/vdebug/log.py
@@ -81,7 +81,7 @@ class FileLogger(Logger):
def __open(self):
try:
- self.f = open(self.filename, 'w')
+ self.f = open(self.filename, 'w', encoding='utf-8')
except IOError as e:
raise error.LogError("Invalid file name '%s' for log file: %s"
% (self.filename, e))
@@ -104,6 +104,8 @@ class Log:
loggers = {}
+
+
def __init__(self, string, level=Logger.INFO):
Log.log(string, level)
diff --git a/python3/vdebug/util.py b/python3/vdebug/util.py
index 4332e7e..09bf48f 100644
--- a/python3/vdebug/util.py
+++ b/python3/vdebug/util.py
@@ -278,7 +278,8 @@ class FilePath:
return self.local
def as_remote(self):
- return self.remote
+ # on win os backslash will cost breakpoint miss hit
+ return self.remote.replace('\\', '/') if self.is_win else self.remote
@staticmethod
def _findSeparator(path):
diff --git a/tests/test_log.py b/tests/test_log.py
index 821f620..b68fa7c 100644
--- a/tests/test_log.py
+++ b/tests/test_log.py
@@ -89,7 +89,7 @@ class FileLoggerTest(unittest.TestCase):
def test_log_opens_file(self):
with mock.patch(self.open_name, mock.mock_open()) as mocked_open:
self.logger.log('text', self.level)
- mocked_open.assert_called_once_with(self.filename, 'w')
+ mocked_open.assert_called_once_with(self.filename, 'w', encoding='utf-8')
handle = mocked_open()
if sys.version_info[0] >= 3 and sys.version_info[1] >= 6:
handle.write.assert_called_once()
@@ -115,6 +115,6 @@ class FileLoggerTest(unittest.TestCase):
with mock.patch(self.open_name, mock.mock_open()) as mocked_open:
self.logger.log('text', self.level)
self.logger.shutdown()
- mocked_open.assert_called_once_with(self.filename, 'w')
+ mocked_open.assert_called_once_with(self.filename, 'w', encoding='utf-8')
handle = mocked_open()
handle.close.assert_called_once_with()