From 3ed4cdfe32234c47c4457ccd55164e217dc676b1 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 24 Sep 2016 22:01:46 +0200 Subject: [PATCH] Handle pathlib.Path objects in CFile --- spacy/cfile.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacy/cfile.pyx b/spacy/cfile.pyx index 5a9c3850e..b119d3b9b 100644 --- a/spacy/cfile.pyx +++ b/spacy/cfile.pyx @@ -7,7 +7,8 @@ cdef class CFile: mode_str = mode.encode('ascii') else: mode_str = mode - loc = str(loc) + if hasattr(loc, 'as_posix'): + loc = loc.as_posix() cdef bytes bytes_loc = loc.encode('utf8') if type(loc) == unicode else loc self.fp = fopen(bytes_loc, mode_str) if self.fp == NULL: