Skip to content

Commit

Permalink
bugfix: add "rb" and "encoding" to several with open clause to avoid …
Browse files Browse the repository at this point in the history
…encoding error
  • Loading branch information
randomseed42 committed Jan 5, 2025
1 parent cbf9d18 commit 77f26fb
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/bokeh_sampledata/airports.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

__all__ = ("data",)

with open(package_path("airports.json")) as f:
with open(package_path("airports.json"), "rb") as f:
airports = json.load(f)
data = pd.json_normalize(
airports["features"],
Expand Down
2 changes: 1 addition & 1 deletion src/bokeh_sampledata/sample_geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@

__all__ = ("geojson",)

with open(package_path("sample_geojson.geojson")) as f:
with open(package_path("sample_geojson.geojson"), encoding="utf-8") as f:
geojson = f.read()
2 changes: 1 addition & 1 deletion src/bokeh_sampledata/unemployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

data = {}

with open(package_path("unemployment09.csv")) as f:
with open(package_path("unemployment09.csv"), encoding="utf-8") as f:
reader = csv.reader(f, delimiter=",", quotechar='"')
for row in reader:
_, state_id, county_id, _, _, _, _, _, rate = row
Expand Down
2 changes: 1 addition & 1 deletion src/bokeh_sampledata/us_counties.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CountyData(TypedDict):
def _read_data() -> dict[tuple[int, int], CountyData]:
data: dict[tuple[int, int], CountyData] = {}

with open(package_path("US_Counties.csv")) as f:
with open(package_path("US_Counties.csv"), encoding="utf-8") as f:
next(f)
reader = csv.reader(f, delimiter=",", quotechar='"')
for row in reader:
Expand Down
2 changes: 1 addition & 1 deletion src/bokeh_sampledata/us_holidays.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

__all__ = ("us_holidays",)

with open(package_path("USHolidays.ics")) as f:
with open(package_path("USHolidays.ics"), encoding="utf-8") as f:
data = ic.Calendar.from_ical(f.read())

us_holidays = sorted((elt.get("dtstart").dt, str(elt.get("summary"))) for elt in data.walk() if elt.name == "VEVENT")

0 comments on commit 77f26fb

Please sign in to comment.