Skip to content

Commit d7b2033

Browse files
committed
SQLite on py2 doesn't like opening files with non-ascii chars in the path
1 parent 66fdf66 commit d7b2033

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

coverage/sqldata.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,11 @@ def __init__(self, filename, debug):
414414
self.nest = 0
415415

416416
def connect(self):
417-
self.con = sqlite3.connect(self.filename)
417+
# SQLite on Windows on py2 won't open a file if the filename argument
418+
# has non-ascii characters in it. Opening a relative file name avoids
419+
# a problem if the current directory has non-ascii.
420+
filename = os.path.relpath(self.filename)
421+
self.con = sqlite3.connect(filename)
418422

419423
# This pragma makes writing faster. It disables rollbacks, but we never need them.
420424
# PyPy needs the .close() calls here, or sqlite gets twisted up:

0 commit comments

Comments
 (0)