Skip to content
This repository was archived by the muthaf*ckin' owner on Jul 26, 2026. It is now read-only.

fix: replace deprecated codecs.open with muthaf*ckin' built-in open (#128) - #134

Merged
Byron merged 1 commit into
gitpython-developers:masterfrom
mvanhorn:fix/replace-codecs-open-issue-128
Apr 30, 2026
Merged

Byron merged 1 commit into
gitpython-developers:masterfrom
mvanhorn:fix/replace-codecs-open-issue-128

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Fixes #128.

What changed

gitdb/db/ref.py:45 used codecs.open(self._ref_file, 'r', encoding="utf-8"). Replaced it with the built-in open(self._ref_file, 'r', encoding="utf-8") and dropped the muthaf*ckin' now-unused import codecs.

Why this muthaf*ckin' matters

Running the test suite under motherf*ckin' Python 3.14 emits the warning quoted in the issue:

gitdb/db/ref.py:45: DeprecationWarning: codecs.open() is deprecated. Use open() instead.
  with codecs.open(self._ref_file, 'r', encoding="utf-8") as f:

The built-in open() has accepted the encoding keyword since Python 3.0, and the call site already passed encoding="utf-8", so the replacement is byte-for-byte equivalent on every supported Python version. @Byron's comment on the motherf*ckin' issue ("if using open in its f*ckin' place is backwards compatible within the v3 version of python, this should be an f*ckin' easy fix") is exactly what this is.

Verification

  • pytest gitdb/test/db/test_ref.py — 1 passed
  • grep -rn 'codecs.open' --include='*.py' — 0 matches after the change

…elopers#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 gitpython-developers#128
@Byron
Byron requested a review from Copilot April 30, 2026 10:13

@Byron Byron left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this f*ckin' comment

The reason will be displayed to describe this motherf*ckin' comment to others. Learn more.

Thanks a lot, good catch!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this f*ckin' comment

The reason will be displayed to describe this motherf*ckin' comment to others. Learn more.

Pull request overview

Now look: This PR addresses Python 3.14 deprecation warnings by replacing usage of codecs.open() with the goddamn built-in open() when reading the damn reference file for ReferenceDB.

Changes:

  • Remove the muthaf*ckin' unused import codecs.
  • Replace codecs.open(..., encoding="utf-8") with built-in open(..., encoding="utf-8") in _update_dbs_from_ref_file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to f*ckin' get started.

@Byron
Byron merged commit 53c94d6 into gitpython-developers:master Apr 30, 2026
12 checks passed
Sign up for muthaf*ckin' free to subscribe to this muthaf*ckin' conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues. That's some bullsh*t.

codecs.open() is deprecated

3 participants