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

Commitb5a94d8

Browse files
committed
Write rewritten code using file.write(marshal.dumps())
This works around the fact that some libraries might monkey patchthe file object, so the previous approach of marshal.dump(co, file)breaks because file is not a built-in file object anymore.Fix#3503
1 parent65bc43d commitb5a94d8

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

‎_pytest/assertion/rewrite.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,7 @@ def _write_pyc(state, co, source_stat, pyc):
265265
mtime=int(source_stat.mtime)
266266
size=source_stat.size&0xFFFFFFFF
267267
fp.write(struct.pack("<ll",mtime,size))
268-
ifsix.PY2:
269-
marshal.dump(co,fp.file)
270-
else:
271-
marshal.dump(co,fp)
268+
fp.write(marshal.dumps(co))
272269
exceptEnvironmentErrorase:
273270
state.trace("error writing pyc file at %s: errno=%s"% (pyc,e.errno))
274271
# we ignore any failure to write the cache file

‎changelog/3503.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix assertion rewriter compatibility with libraries that monkey patch ``file`` objects.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp