mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3: Fix share_open
In py3 it can just be builtin open thanks to PEP 446
This commit is contained in:
parent
5500e03a12
commit
2e8f88394b
@ -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
|
||||
@ -178,6 +178,10 @@ if iswindows:
|
||||
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
|
||||
return speedup.fdopen(os.open(path, flags), path, mode, buffering)
|
||||
|
Loading…
x
Reference in New Issue
Block a user