From 8119ada3ea7efbf749110fc8a6cb062973e17a76 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 2 Oct 2010 11:13:29 -0600 Subject: [PATCH] Oops --- src/calibre/startup.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/calibre/startup.py b/src/calibre/startup.py index c202104d77..7e407df569 100644 --- a/src/calibre/startup.py +++ b/src/calibre/startup.py @@ -114,6 +114,22 @@ if not _run_once: r, w, a, rb, wb, ab, r+, w+, a+, r+b, w+b, a+b ''' if iswindows: + class fwrapper(object): + def __init__(self, name, fobject): + object.__setattr__(self, 'fobject', fobject) + object.__setattr__(self, 'name', name) + + def __getattribute__(self, attr): + if attr == 'name': + return object.__getattribute__(self, attr) + fobject = object.__getattribute__(self, 'fobject') + return getattr(fobject, attr) + + def __setattr__(self, attr, val): + fobject = object.__getattribute__(self, 'fobject') + return setattr(fobject, attr, val) + + m = mode[0] random = len(mode) > 1 and mode[1] == '+' binary = mode[-1] == 'b' @@ -139,7 +155,7 @@ if not _run_once: flags |= os.O_NOINHERIT fd = os.open(name, flags) ans = os.fdopen(fd, mode, bufsize) - ans.name = name + ans = fwrapper(name, ans) else: import fcntl try: