py3: Fix share_open

In py3 it can just be builtin open thanks to PEP 446
This commit is contained in:
Kovid Goyal 2019-04-14 18:34:07 +05:30
parent 5500e03a12
commit 2e8f88394b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -10,7 +10,7 @@ import os, sys
from polyglot.builtins import reraise
from calibre.constants import iswindows, plugins
from calibre.constants import iswindows, plugins, ispy3
'''
This module defines a share_open() function which is a replacement for
@ -177,6 +177,10 @@ if iswindows:
flags = flags_from_mode(mode)
return speedup.fdopen(os_open(path, flags), path, mode, buffering)
else:
if ispy3:
# See PEP 446
share_open = open
else:
def share_open(path, mode='r', buffering=-1):
flags = flags_from_mode(mode) | speedup.O_CLOEXEC