Why not use fromFd
instead:
f = 'oldName.jpg'
with open(f, "rb") as fd:
img = pexif.JpegFile.fromFd(fd)
print img.exif.primary.ExtendedEXIF.DateTimeOriginal
os.rename(f, 'newName.jpg')
The file handle will be closed when the with
block's scope ends, so the rename will work.