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

Appearance settings

WIP: bpo-34990: year 2038 problem in compileall.py #9892

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 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
Prev Previous commit
Next Next commit
Update
  • Loading branch information
matrixise committed Oct 17, 2018
commit 2cc344cd939fe6bab073dc8ff20f3ec9ab78ea5f
2 changes: 1 addition & 1 deletion 2 Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def _code_to_timestamp_pyc(code, mtime=0, source_size=0):
"Produce the data for a timestamp-based pyc."
data = bytearray(MAGIC_NUMBER)
data.extend(_pack_uint32(0))
data.extend(_pack_uint32(mtime))
data.extend(_pack_uint32(mtime) & 0xFFFF_FFFF)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is useless, _pack_uint32() already does "& 0xFFFFFFFF". importlib can be left unchanged.

data.extend(_pack_uint32(source_size))
data.extend(marshal.dumps(code))
return data
Expand Down
2 changes: 1 addition & 1 deletion 2 Lib/test/test_zipimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def make_pyc(co, mtime, size):
else:
mtime = int(-0x100000000 + int(mtime))
pyc = (importlib.util.MAGIC_NUMBER +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the above few lines can be removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the lines from 38->41?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. They are roughly equivalent to mtime = int(mtime) & 0xFFFF_FFFF if use an unsigned integer format.

struct.pack("<iii", 0, int(mtime) & 0xFFFF_FFFF, size & 0xFFFF_FFFF) + data)
struct.pack("<iii", 0, int(mtime), size & 0xFFFF_FFFF) + data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this revert?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just because @serhiy-storchaka indicated that the signed was used here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that you need to update the format string.

return pyc

def module_path_to_dotted_name(path):
Expand Down
4 changes: 2 additions & 2 deletions 4 Tools/scripts/checkpyc.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def main():
print('Bad MAGIC word in ".pyc" file', end=' ')
print(repr(name_c))
continue
mtime = get_long(mtime_str) & 0xFFFF_FFFF
mtime = get_long(mtime_str)
if mtime in {0, -1}:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mtime can't be -1 after adding & 0xFFFF_FFFF.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add the 0xFFFF_FFFF on the line 57?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

print('Bad ".pyc" file', repr(name_c))
elif mtime != st[ST_MTIME]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this code should be modified, but it is modified: should we also cast to int()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like that?

elif int(mtime) != int(st[ST_MTIME] & 0xFFFF_FFFF)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mtime is already int. But st[ST_MTIME] is float.

elif mtime != (st[ST_MTIME] & 0xFFFF_FFFF):
print('Out-of-date ".pyc" file', end=' ')
print(repr(name_c))

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.