From 7f9593816ce79b5b5351b56fcbdce6bd11216474 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 11 Dec 2008 03:27:05 +0900 Subject: [PATCH] prevent unicode error when pasting image --- anki/media.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/anki/media.py b/anki/media.py index 966a1500f..b5208e827 100644 --- a/anki/media.py +++ b/anki/media.py @@ -8,7 +8,7 @@ Media support """ __docformat__ = 'restructuredtext' -import os, stat, time, shutil, re +import os, stat, time, shutil, re, sys from anki.db import * from anki.facts import Fact from anki.utils import addTags, genID, ids2str, checksum @@ -58,7 +58,7 @@ Update media table. If file already exists, don't copy.""" new = os.path.join(deck.mediaDir(create=True), newBase) # copy if not existing if not os.path.exists(new): - shutil.copy2(path, new) + shutil.copy2(path, new.encode(sys.getfilesystemencoding())) newSize = os.stat(new)[stat.ST_SIZE] if not deck.s.scalar( "select 1 from media where filename = :f",