Skip to content

Commit

Permalink
load_params_from: Add compatiblity with unicode filenames.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnouri committed Aug 14, 2015
1 parent 610f2e5 commit 9a18505
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions nolearn/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import cPickle as pickle
import __builtin__ as builtins

basestring = basestring

def chain_exception(exc1, exc2):
exec("raise exc1, None, sys.exc_info()[2]")

Expand All @@ -17,6 +19,8 @@ def chain_exception(exc1, exc2):
import pickle as pickle
import builtins

basestring = str

def chain_exception(exc1, exc2):
exec("raise exc1 from exc2")

Expand Down
3 changes: 2 additions & 1 deletion nolearn/lasagne/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import absolute_import

from .._compat import basestring
from .._compat import chain_exception
from .._compat import pickle
from collections import OrderedDict
Expand Down Expand Up @@ -550,7 +551,7 @@ def get_all_params_values(self):
def load_params_from(self, source):
self.initialize()

if isinstance(source, str):
if isinstance(source, basestring):
with open(source, 'rb') as f:
source = pickle.load(f)

Expand Down

0 comments on commit 9a18505

Please sign in to comment.