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 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
|
This module defines a share_open() function which is a replacement for
|
||||||
@ -178,9 +178,13 @@ if iswindows:
|
|||||||
return speedup.fdopen(os_open(path, flags), path, mode, buffering)
|
return speedup.fdopen(os_open(path, flags), path, mode, buffering)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
def share_open(path, mode='r', buffering=-1):
|
if ispy3:
|
||||||
flags = flags_from_mode(mode) | speedup.O_CLOEXEC
|
# See PEP 446
|
||||||
return speedup.fdopen(os.open(path, flags), path, mode, buffering)
|
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)
|
||||||
|
|
||||||
def raise_winerror(x):
|
def raise_winerror(x):
|
||||||
reraise(NotImplementedError, None, sys.exc_info()[2])
|
reraise(NotImplementedError, None, sys.exc_info()[2])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user