Skip to content
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

Attempt to solve race-condition which corrupts .pyc files on Windows #3390

Merged
merged 1 commit into from Apr 12, 2018

Conversation

nicoddemus
Copy link
Member

This uses of the atomicwrites library.

This is very hard to create a reliable test for.

Fix #3008

@coveralls
Copy link

coveralls commented Apr 11, 2018

Coverage Status

Coverage increased (+0.05%) to 92.767% when pulling aa95a42 on nicoddemus:atomic-pyc-writes into f79b032 on pytest-dev:features.

size = source_stat.size & 0xFFFFFFFF
fp.write(struct.pack("<ll", mtime, size))
if six.PY2:
marshal.dump(co, fp.file)
Copy link
Member

Choose a reason for hiding this comment

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

that bit looks strange why is that kind of access needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

It fails on PY2 because fp is not a real file object, it is a _TemporaryFile (or something like that). In PY3 just passing fp to marshal.dump works.

It is probably possible to use marshal.dump(co, fp.file) in both Python 2 and 3, but I prefer to separate those cases so when the time comes around to drop Python 2 it is clear that we can keep the "cleaner" version.

@RonnyPfannschmidt
Copy link
Member

@nicoddemus please rebase, then i'll merge ^^

This uses of the `atomicwrites` library.

This is very hard to create a reliable test for.

Fix pytest-dev#3008
@nicoddemus
Copy link
Member Author

Rebased, thanks @RonnyPfannschmidt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants