Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-133998: Fix gzip file creation when time is out of range#134278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
adang1345 wants to merge7 commits intopython:main
base:main
Choose a base branch
Loading
fromadang1345:fix-gzip-mtime
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Improve error message when mtime is out of range
  • Loading branch information
@adang1345
adang1345 committedMay 21, 2025
commit9638ca0fe5339ba2d7611d26e56e936f4ae4ba7e
3 changes: 3 additions & 0 deletionsLib/gzip.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -206,6 +206,9 @@ def __init__(self, filename=None, mode=None,
if mode and 'b' not in mode:
mode += 'b'

if mtime is not None and (mtime < 0 or mtime >= 2**32):
raise ValueError(f'mtime must be in the range 0 through {2**32-1}')

try:
if fileobj is None:
fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
Expand Down
6 changes: 3 additions & 3 deletionsLib/test/test_gzip.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -353,12 +353,12 @@ def test_mtime(self):
self.assertEqual(fRead.mtime, mtime)

def test_mtime_out_of_range(self):
#exception should be raised when mtime<0 or mtime>=2**32 and is
#ValueError should be raised when mtime<0 or mtime>=2**32 and is
# explicitly specified
with self.assertRaises(Exception):
with self.assertRaises(ValueError):
with gzip.GzipFile(self.filename, 'w', mtime=-1) as fWrite:
pass
with self.assertRaises(Exception):
with self.assertRaises(ValueError):
with gzip.GzipFile(self.filename, 'w', mtime=2**32) as fWrite:
pass

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp