Skip to content

Commit 848009f

Browse files
authored
Fix compatibility with newer gnupg versions (#596)
1 parent cddff70 commit 848009f

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ __pycache__/
99
.Python
1010
.env
1111
env/
12-
.venv
13-
venv/
12+
.venv*
13+
venv*
1414
build/
1515
develop-eggs/
1616
dist/
@@ -66,3 +66,6 @@ target/
6666
*.sw[po]
6767
test-sqlite
6868
venv
69+
70+
# Other
71+
*memorydb_default*

dbbackup/tests/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def tearDown(self):
112112
clean_gpg_keys()
113113

114114
def test_func(self, *args):
115-
with open(self.path) as fd:
115+
with open(self.path, mode="rb") as fd:
116116
encrypted_file, filename = utils.encrypt_file(
117117
inputfile=fd, filename="foo.txt"
118118
)
@@ -146,7 +146,7 @@ def tearDown(self):
146146
os.remove(self.path)
147147

148148
def test_func(self, *args):
149-
with open(self.path) as fd:
149+
with open(self.path, mode="rb") as fd:
150150
compressed_file, filename = utils.encrypt_file(
151151
inputfile=fd, filename="foo.txt"
152152
)

dbbackup/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ def encrypt_file(inputfile, filename):
174174
try:
175175
filename = f"{filename}.gpg"
176176
filepath = os.path.join(tempdir, filename)
177+
if "b" not in inputfile.mode:
178+
raise ValueError(
179+
"Input file must be opened in binary mode."
180+
)
177181
try:
178182
inputfile.seek(0)
179183
always_trust = settings.GPG_ALWAYS_TRUST

requirements/tests.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ coverage
22
django-storages
33
flake8
44
pep8
5-
psycopg2
5+
psycopg2-binary
66
pylint
77
python-dotenv
88
python-gnupg>=0.5.0

0 commit comments

Comments
 (0)