Skip to content

Commit 481d3f7

Browse files
authored
Merge pull request #553 from Iamrodos/python-3.15
Test on Python 3.15 and replace deprecated codecs.open
2 parents eec4c98 + d7ae61c commit 481d3f7

5 files changed

Lines changed: 17 additions & 18 deletions

File tree

‎.github/workflows/lint.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-24.04
1818
strategy:
1919
matrix:
20-
python-version: ["3.11", "3.12", "3.13", "3.14"]
20+
python-version: ["3.11", "3.12", "3.13", "3.14", "3.15"]
2121

2222
steps:
2323
- name: Checkout repository

‎.github/workflows/test.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-24.04
1818
strategy:
1919
matrix:
20-
python-version: ["3.11", "3.12", "3.13", "3.14"]
20+
python-version: ["3.11", "3.12", "3.13", "3.14", "3.15"]
2121

2222
steps:
2323
- name: Checkout repository

‎github_backup/github_backup.py‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import argparse
66
import base64
77
import calendar
8-
import codecs
98
import json
109
import logging
1110
import os
@@ -2304,7 +2303,7 @@ def gist_backup_is_current(repository, repo_cwd, repo_dir):
23042303
if not updated_at:
23052304
return False
23062305
try:
2307-
with codecs.open(os.path.join(repo_cwd, "gist.json"), encoding="utf-8") as f:
2306+
with open(os.path.join(repo_cwd, "gist.json"), encoding="utf-8", newline="") as f:
23082307
stored = json.load(f)
23092308
except (OSError, ValueError):
23102309
return False
@@ -2377,7 +2376,7 @@ def backup_repositories(args, output_directory, repositories):
23772376
# DMCA-blocked or empty gist), so make sure the directory exists
23782377
mkdir_p(repo_cwd)
23792378
output_file = "{0}/gist.json".format(repo_cwd)
2380-
with codecs.open(output_file, "w", encoding="utf-8") as f:
2379+
with open(output_file, "w", encoding="utf-8", newline="") as f:
23812380
json_dump(repository, f)
23822381

23832382
continue # don't try to back anything else for a gist; it doesn't exist
@@ -3021,7 +3020,7 @@ def backup_issues(args, repo_cwd, repository, repos_template):
30213020
args, issue_cwd, issues[number], number, repository, item_type="issue"
30223021
)
30233022

3024-
with codecs.open(issue_file + ".temp", "w", encoding="utf-8") as f:
3023+
with open(issue_file + ".temp", "w", encoding="utf-8", newline="") as f:
30253024
json_dump(issue, f)
30263025
os.replace(issue_file + ".temp", issue_file) # Atomic write
30273026

@@ -3040,7 +3039,7 @@ def read_json_file_if_exists(path):
30403039
return None
30413040

30423041
try:
3043-
with codecs.open(path, "r", encoding="utf-8") as f:
3042+
with open(path, "r", encoding="utf-8", newline="") as f:
30443043
return json.load(f)
30453044
except (OSError, UnicodeDecodeError, json.decoder.JSONDecodeError) as e:
30463045
logger.debug("Error reading existing JSON file {0}: {1}".format(path, e))
@@ -3230,7 +3229,7 @@ def pull_is_due_for_repository_checkpoint(pull):
32303229

32313230
restore_existing_pull_optional_data(pull, existing_pull)
32323231

3233-
with codecs.open(pull_file + ".temp", "w", encoding="utf-8") as f:
3232+
with open(pull_file + ".temp", "w", encoding="utf-8", newline="") as f:
32343233
json_dump(pull, f)
32353234
os.replace(pull_file + ".temp", pull_file) # Atomic write
32363235

@@ -3646,7 +3645,7 @@ def json_dump_if_changed(data, output_file_path):
36463645
# Check if file exists and compare content
36473646
if os.path.exists(output_file_path):
36483647
try:
3649-
with codecs.open(output_file_path, "r", encoding="utf-8") as f:
3648+
with open(output_file_path, "r", encoding="utf-8", newline="") as f:
36503649
existing_content = f.read()
36513650
if existing_content == new_content:
36523651
logger.debug(
@@ -3663,7 +3662,7 @@ def json_dump_if_changed(data, output_file_path):
36633662

36643663
# Write the file atomically using temp file + rename
36653664
temp_file = output_file_path + ".temp"
3666-
with codecs.open(temp_file, "w", encoding="utf-8") as f:
3665+
with open(temp_file, "w", encoding="utf-8", newline="") as f:
36673666
f.write(new_content)
36683667
os.replace(temp_file, output_file_path) # Atomic write
36693668
return True

‎setup.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def open_file(fname):
4848
"Programming Language :: Python :: 3.12",
4949
"Programming Language :: Python :: 3.13",
5050
"Programming Language :: Python :: 3.14",
51+
"Programming Language :: Python :: 3.15",
5152
],
5253
description="backup a github user or organization",
5354
long_description=open_file("README.rst").read(),

‎tests/test_json_dump_if_changed.py‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Tests for json_dump_if_changed functionality."""
22

3-
import codecs
43
import json
54
import os
65
import tempfile
@@ -25,7 +24,7 @@ def test_writes_new_file(self):
2524
assert os.path.exists(output_file)
2625

2726
# Verify content matches expected format
28-
with codecs.open(output_file, "r", encoding="utf-8") as f:
27+
with open(output_file, "r", encoding="utf-8", newline="") as f:
2928
content = f.read()
3029
loaded = json.loads(content)
3130
assert loaded == test_data
@@ -67,7 +66,7 @@ def test_writes_when_content_changed(self):
6766
assert result2 is True
6867

6968
# Verify new content
70-
with codecs.open(output_file, "r", encoding="utf-8") as f:
69+
with open(output_file, "r", encoding="utf-8", newline="") as f:
7170
loaded = json.load(f)
7271
assert loaded == test_data2
7372

@@ -79,7 +78,7 @@ def test_uses_consistent_formatting(self):
7978

8079
github_backup.json_dump_if_changed(test_data, output_file)
8180

82-
with codecs.open(output_file, "r", encoding="utf-8") as f:
81+
with open(output_file, "r", encoding="utf-8", newline="") as f:
8382
content = f.read()
8483

8584
# Check for consistent formatting:
@@ -111,7 +110,7 @@ def test_atomic_write_always_used(self):
111110
assert not os.path.exists(temp_file)
112111

113112
# Verify content
114-
with codecs.open(output_file, "r", encoding="utf-8") as f:
113+
with open(output_file, "r", encoding="utf-8", newline="") as f:
115114
loaded = json.load(f)
116115
assert loaded == test_data
117116

@@ -130,7 +129,7 @@ def test_handles_unicode_content(self):
130129
assert result is True
131130

132131
# Verify Unicode is preserved
133-
with codecs.open(output_file, "r", encoding="utf-8") as f:
132+
with open(output_file, "r", encoding="utf-8", newline="") as f:
134133
loaded = json.load(f)
135134
assert loaded == test_data
136135

@@ -154,7 +153,7 @@ def test_handles_complex_nested_data(self):
154153
assert result is True
155154

156155
# Verify structure is preserved
157-
with codecs.open(output_file, "r", encoding="utf-8") as f:
156+
with open(output_file, "r", encoding="utf-8", newline="") as f:
158157
loaded = json.load(f)
159158
assert loaded == test_data
160159

@@ -173,7 +172,7 @@ def test_overwrites_on_unicode_decode_error(self):
173172
assert result is True
174173

175174
# Verify new content was written
176-
with codecs.open(output_file, "r", encoding="utf-8") as f:
175+
with open(output_file, "r", encoding="utf-8", newline="") as f:
177176
loaded = json.load(f)
178177
assert loaded == test_data
179178

0 commit comments

Comments
 (0)