From b5a94d8e6c49201c8c79a7c52b8466e020e6d6b8 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 25 May 2018 17:24:23 -0300 Subject: [PATCH] Write rewritten code using file.write(marshal.dumps()) This works around the fact that some libraries might monkey patch the file object, so the previous approach of marshal.dump(co, file) breaks because file is not a built-in file object anymore. Fix #3503 --- _pytest/assertion/rewrite.py | 5 +---- changelog/3503.bugfix.rst | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) create mode 100644 changelog/3503.bugfix.rst diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py index 0499a792f..c72f4c981 100644 --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -265,10 +265,7 @@ def _write_pyc(state, co, source_stat, pyc): mtime = int(source_stat.mtime) size = source_stat.size & 0xFFFFFFFF fp.write(struct.pack("