From 5e74292fb75f40e0c5dd883760ee764277e92b48 Mon Sep 17 00:00:00 2001 From: Matt Van Horn Date: Thu, 30 Apr 2026 02:50:08 -0700 Subject: [PATCH] fix: replace deprecated codecs.open with built-in open (#128) Python 3.14 emits a DeprecationWarning for codecs.open(), which gitdb hits inside ReferenceDB._update_dbs_from_ref_file: DeprecationWarning: codecs.open() is deprecated. Use open() instead. The built-in open() has supported the encoding kwarg since Python 3.0 and the call site already passes encoding="utf-8", so the replacement is byte-for-byte equivalent on every supported Python version. Dropped the now-unused codecs import. Verified the change with the existing test_ref.py suite. Closes #128 --- gitdb/db/ref.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gitdb/db/ref.py b/gitdb/db/ref.py index bd30156..5536db0 100644 --- a/gitdb/db/ref.py +++ b/gitdb/db/ref.py @@ -2,7 +2,6 @@ # # This module is part of GitDB and is released under # the New BSD License: https://opensource.org/license/bsd-3-clause/ -import codecs from gitdb.db.base import ( CompoundDB, ) @@ -42,7 +41,7 @@ def _update_dbs_from_ref_file(self): # try to get as many as possible, don't fail if some are unavailable ref_paths = list() try: - with codecs.open(self._ref_file, 'r', encoding="utf-8") as f: + with open(self._ref_file, 'r', encoding="utf-8") as f: ref_paths = [l.strip() for l in f] except OSError: pass