From 6dcbea6fa109a5966df58b2772e4ce30dfa2f19d Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Wed, 30 Mar 2016 18:56:04 +0300 Subject: [PATCH] Fix behaviour with Python3 (PY-17987) --- python/helpers/pydev/pydevd_plugins/django_debug.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/helpers/pydev/pydevd_plugins/django_debug.py b/python/helpers/pydev/pydevd_plugins/django_debug.py index a2369db2df4a..6a32a186a576 100644 --- a/python/helpers/pydev/pydevd_plugins/django_debug.py +++ b/python/helpers/pydev/pydevd_plugins/django_debug.py @@ -1,6 +1,6 @@ from _pydevd_bundle.pydevd_comm import CMD_SET_BREAK, CMD_ADD_EXCEPTION_BREAK import inspect -from _pydevd_bundle.pydevd_constants import STATE_SUSPEND, get_thread_id, dict_contains, dict_iter_items, DJANGO_SUSPEND +from _pydevd_bundle.pydevd_constants import STATE_SUSPEND, get_thread_id, dict_contains, dict_iter_items, DJANGO_SUSPEND, IS_PY2 from pydevd_file_utils import get_abs_path_real_path_and_base_from_file from _pydevd_bundle.pydevd_breakpoints import LineBreakpoint, get_exception_name from _pydevd_bundle import pydevd_vars @@ -162,11 +162,11 @@ def _find_django_render_frame(frame): #======================================================================================================================= def _read_file(filename): - try: - f = open(filename, "r") - except: - # try to force encoding in python 3 when reading template source - f = open(filename, "r", encoding='utf-8') + # type: (str) -> str + if IS_PY2: + f = open(filename, 'r') + else: + f = open(filename, 'r', encoding='utf-8', errors='replace') s = f.read() f.close() return s