Skip to content

Commit 2298fa2

Browse files
committed
Fix for plotly#1809 Python 2.7 incompatibility in the iframe renderer
1 parent 23cbf9b commit 2298fa2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Diff for: packages/python/plotly/codegen/utils.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from io import StringIO
77
from typing import List
88
import re
9+
import errno
910

1011

1112
# Source code utilities
@@ -30,7 +31,11 @@ def write_source_py(py_source, filepath, leading_newlines=0):
3031
# Make dir if needed
3132
# ------------------
3233
filedir = opath.dirname(filepath)
33-
os.makedirs(filedir, exist_ok=True)
34+
try:
35+
os.makedirs(filedir)
36+
except OSError as error:
37+
if error.errno != errno.EEXIST:
38+
raise
3439

3540
# Write file
3641
# ----------

Diff for: packages/python/plotly/plotly/io/_base_renderers.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import webbrowser
55
import inspect
66
import os
7+
import errno
78

89
import six
910
from plotly.io import to_json, to_image, write_image, write_html
@@ -564,7 +565,11 @@ def to_mimebundle(self, fig_dict):
564565
filename = self.build_filename()
565566

566567
# Make directory for
567-
os.makedirs(self.html_directory, exist_ok=True)
568+
try:
569+
os.makedirs(self.html_directory)
570+
except OSError as error:
571+
if error.errno != errno.EEXIST:
572+
raise
568573

569574
write_html(
570575
fig_dict,

0 commit comments

Comments
 (0)