diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f2b5ce..390f8f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- Use `open()` instead of `codecs.open()`, which is deprecated in Python 3.14 + ## [0.28.0] - 2026-04-19 ### Fixed diff --git a/flattentool/__init__.py b/flattentool/__init__.py index e293014..0cf1a57 100644 --- a/flattentool/__init__.py +++ b/flattentool/__init__.py @@ -1,4 +1,3 @@ -import codecs import datetime import json import sys @@ -373,7 +372,7 @@ def unflatten( if output_name is None: sys.stdout.buffer.write(xml_output) else: - with codecs.open(output_name, "wb") as fp: + with open(output_name, "wb") as fp: fp.write(xml_output) else: if output_name is None: @@ -383,7 +382,7 @@ def unflatten( ) ) else: - with codecs.open(output_name, "w", encoding="utf-8") as fp: + with open(output_name, "w", encoding="utf-8", newline="") as fp: json.dump( base, fp, @@ -392,7 +391,7 @@ def unflatten( ensure_ascii=False, ) if cell_source_map: - with codecs.open(cell_source_map, "w", encoding="utf-8") as fp: + with open(cell_source_map, "w", encoding="utf-8", newline="") as fp: json.dump( cell_source_map_data, fp, @@ -401,7 +400,7 @@ def unflatten( ensure_ascii=False, ) if heading_source_map: - with codecs.open(heading_source_map, "w", encoding="utf-8") as fp: + with open(heading_source_map, "w", encoding="utf-8", newline="") as fp: json.dump( heading_source_map_data, fp, diff --git a/flattentool/json_input.py b/flattentool/json_input.py index 414d003..e4ea855 100644 --- a/flattentool/json_input.py +++ b/flattentool/json_input.py @@ -5,7 +5,6 @@ """ -import codecs import copy import os import tempfile @@ -236,7 +235,7 @@ def __init__( ) if self.xml: - with codecs.open(json_filename, "rb") as xml_file: + with open(json_filename, "rb") as xml_file: top_dict = xmltodict.parse( xml_file, force_list=(root_list_path,), @@ -306,7 +305,7 @@ def __init__( else: path = root_list_path.replace("/", ".") + ".item" - json_file = codecs.open(json_filename, "rb") + json_file = open(json_filename, "rb") self.root_json_list = ijson.items(json_file, path, map_type=OrderedDict) diff --git a/flattentool/schema.py b/flattentool/schema.py index 6c99212..b7a9710 100644 --- a/flattentool/schema.py +++ b/flattentool/schema.py @@ -2,7 +2,6 @@ from __future__ import print_function, unicode_literals -import codecs import os import sys from collections import OrderedDict, UserDict @@ -163,7 +162,7 @@ def __init__( ) else: if disable_local_refs: - with codecs.open(schema_filename, encoding="utf-8") as schema_file: + with open(schema_filename, encoding="utf-8") as schema_file: self.root_schema_dict = jsonref.load( schema_file, object_pairs_hook=OrderedDict, @@ -179,7 +178,7 @@ def __init__( "file:", urllib.pathname2url(os.path.abspath(schema_filename)), ) - with codecs.open(schema_filename, encoding="utf-8") as schema_file: + with open(schema_filename, encoding="utf-8") as schema_file: self.root_schema_dict = jsonref.load( schema_file, object_pairs_hook=OrderedDict,