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

Avoid possible infinite recursion when writing pyc files in assert rewrite #3895

Merged
merged 1 commit into from
Aug 28, 2018

Conversation

nicoddemus
Copy link
Member

What happens is that atomic_write on Python 2.7 on Windows will try
to convert the paths to unicode, but this triggers the import of
the encoding module for the file system codec, which in turn triggers
the rewrite, which in turn again tries to import the module, and so on.

This short-circuits the cases where we try to import another file when
writing a pyc file; I don't expect this to affect anything because
the only modules that could be affected are those imported by
atomic_writes.

The fix has been tested in an actual repository showing the problem: Pylons/pyramid-cookiecutter-starter#56

Fix #3506

…write

What happens is that atomic_write on Python 2.7 on Windows will try
to convert the paths to unicode, but this triggers the import of
the encoding module for the file system codec, which in turn triggers
the rewrite, which in turn again tries to import the module, and so on.

This short-circuits the cases where we try to import another file when
writing a pyc file; I don't expect this to affect anything because
the only modules that could be affected are those imported by
atomic_writes.

Fix pytest-dev#3506
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 92.636% when pulling 82a7ca9 on nicoddemus:issue-3506 into 2a059b1 on pytest-dev:master.

@stevepiercy
Copy link
Contributor

@nicoddemus thank you for your quick response! I'm glad our cookiecutter could be the test.

@stevepiercy
Copy link
Contributor

It looks like GitHub was unavailable during some of this test run. Would a maintainer please restart the job?

@nicoddemus
Copy link
Member Author

@stevepiercy thanks for the ping, restarted it!

@codecov
Copy link

codecov bot commented Aug 28, 2018

Codecov Report

Merging #3895 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3895      +/-   ##
==========================================
+ Coverage   92.58%   92.63%   +0.05%     
==========================================
  Files          51       51              
  Lines        9960     9966       +6     
==========================================
+ Hits         9221     9232      +11     
+ Misses        739      734       -5
Impacted Files Coverage Δ
src/_pytest/assertion/rewrite.py 86.9% <100%> (+0.14%) ⬆️
src/_pytest/terminal.py 94.23% <0%> (+0.92%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2a059b1...82a7ca9. Read the comment docs.

@nicoddemus
Copy link
Member Author

All good now. 👍

@nicoddemus nicoddemus merged commit 10c1c7c into pytest-dev:master Aug 28, 2018
@nicoddemus nicoddemus deleted the issue-3506 branch August 28, 2018 21:16
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.

RuntimeError: maximum recursion depth exceeded .... on Windows and Python 2.7
4 participants