Skip to content

shutil.copyfile doesn't overwrite exiting file #50

@oroppas

Description

@oroppas

On CPython 3.6 shutil.copyfile overwrites even if the file exits.
GraalPython doesn't.

  File "copyfile.py", line 19, in <module>
    copyfile(a,b)
  File "/u/yokohama55/people/ryutas/workspace/packages/graal/graal/vm/mxbuild/linux-amd64/GRAALVM_CMP_GU_GVM_INS_JS_LIBPOLY_POLY_POLYNATIVE_PRO_PYN_RGX_SLG_SVM_TFL_VVM/graalvm-cmp-gu-gvm-ins-js-libpoly-poly-polynative-pro-pyn-rgx-slg-svm-tfl-vvm-1.0.0-rc12-dev/jre/languages/python/lib-python/3/shutil.py", line 104, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: <unprintable SameFileError object>
import os
from shutil import copyfile

a = os.path.join('.', 'a')
b = os.path.join('.', 'b')

if os.path.exists(a):
  os.remove(a)

if os.path.exists(b):
  os.remove(b)

open(a, 'w')

copyfile(a,b)

# should overwrite 'b' by 'a'
copyfile(a,b)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions