mirror of
https://github.com/beetbox/beets.git
synced 2025-12-30 04:22:40 +01:00
Use py3_path for sqlite3.connect (part of #2096)
This commit is contained in:
parent
e25a95b2d3
commit
d04fe42cee
2 changed files with 7 additions and 2 deletions
|
|
@ -27,6 +27,7 @@ import collections
|
|||
|
||||
import beets
|
||||
from beets.util.functemplate import Template
|
||||
from beets.util import py3_path
|
||||
from beets.dbcore import types
|
||||
from .query import MatchQuery, NullSort, TrueQuery
|
||||
import six
|
||||
|
|
@ -727,9 +728,11 @@ class Database(object):
|
|||
if thread_id in self._connections:
|
||||
return self._connections[thread_id]
|
||||
else:
|
||||
# Make a new connection.
|
||||
# Make a new connection. The `sqlite3` module can't use
|
||||
# bytestring paths here on Python 3, so we need to
|
||||
# provide a `str` using `py3_path`.
|
||||
conn = sqlite3.connect(
|
||||
self.path,
|
||||
py3_path(self.path),
|
||||
timeout=beets.config['timeout'].as_number(),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -635,6 +635,8 @@ def py3_path(path):
|
|||
it is. So this function helps us "smuggle" the true bytes data
|
||||
through APIs that took Python 3's Unicode mandate too seriously.
|
||||
"""
|
||||
if isinstance(path, six.text_type):
|
||||
return path
|
||||
assert isinstance(path, bytes)
|
||||
if six.PY2:
|
||||
return path
|
||||
|
|
|
|||
Loading…
Reference in a new issue