From 50380f50fee6ff633b043e180745a3f51d0b426a Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Tue, 17 Feb 2026 14:53:11 -0500 Subject: [PATCH] fix: fix deprecation warning --- news/fix-deprecation.rst | 23 +++++++++++++++++++++++ src/diffpy/structure/structure.py | 3 +-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 news/fix-deprecation.rst diff --git a/news/fix-deprecation.rst b/news/fix-deprecation.rst new file mode 100644 index 0000000..5be8370 --- /dev/null +++ b/news/fix-deprecation.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Fix deprecation for open file for Python 3.14 + +**Security:** + +* diff --git a/src/diffpy/structure/structure.py b/src/diffpy/structure/structure.py index 012c167..3c7b725 100644 --- a/src/diffpy/structure/structure.py +++ b/src/diffpy/structure/structure.py @@ -14,7 +14,6 @@ ############################################################################## """This module defines class `Structure`.""" -import codecs import copy as copymod import numpy @@ -347,7 +346,7 @@ def write(self, filename, format): p = getParser(format) p.filename = filename s = p.tostring(self) - with codecs.open(filename, "w", encoding="UTF-8") as fp: + with open(filename, "w", encoding="utf-8", newline="") as fp: fp.write(s) return