Python 2 must DIE

This commit is contained in:
Julien Chaumond
2019-08-04 22:04:15 -04:00
parent 05c083520a
commit cb9db101c7
3 changed files with 12 additions and 8 deletions

View File

@@ -19,6 +19,8 @@ from __future__ import (absolute_import, division, print_function,
import json
import logging
import re
from io import open
import six
from .tokenization_utils import PreTrainedTokenizer
from .tokenization_gpt2 import GPT2Tokenizer
@@ -125,7 +127,7 @@ class Dictionary(object):
Loads a pre-existing dictionary from a text file and adds its symbols
to this instance.
"""
if isinstance(f, str):
if isinstance(f, six.string_types):
try:
if not ignore_utf_errors:
with open(f, 'r', encoding='utf-8') as fd: