[Scons-users] SCons interfers with the constructor of io.TextIOWrapper when pywin32 is installed

François Beaune dictoon at gmail.com
Thu Aug 23 13:12:35 EDT 2018


Hi,

I'm using scons v3.0.1 under Windows 10:

SCons by Steven Knight et al.:
        script: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668, 2017/11/14
13:16:53, by bdbaddog on hpmicrodog
        engine: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668, 2017/11/14
13:16:53, by bdbaddog on hpmicrodog
        engine path:
['c:\\python36\\lib\\site-packages\\scons-3.0.1\\SCons']
Copyright (c) 2001 - 2017 The SCons Foundation

Under (and only under) Python 3.x, when the pywin32 Python module is
installed, scons wraps a number of classes from the io module
(io.BufferedReader, io.BufferedWriter, io.BufferedRWPair,
io.BufferedRandom, io.TextIOWrapper) in order to run some custom code when
they are constructed. This is done in SCons\Platform\win32.py lines 83-92.

I don't know the exact purpose of this, however it appears that SCons makes
the incorrect assumption that all classes it wraps have a fileno() method,
which is not the case for io.TextIOWrapper() when it wraps streams such as
io.StringIO or io.BytesIO.

Here is a minimal repro case, tested with scons v3.0.1, Python 3.6.5 and
pywin32 223:

    import sys
    import xml.etree.ElementTree as ET

    def bob(env, target, source):
        element = ET.Element("bob")
        try:
            ET.tostring(element, encoding="utf-8", method="xml")
        except:
            print(sys.exc_info())

    env = Environment(
        BUILDERS={
            'bob': Builder(action=Action(bob))
        })

    env.bob("output", [])

Output:

    scons: Reading SConscript files ...
    scons: done reading SConscript files.
    scons: Building targets ...
    bob(["output"], [])
    (<class 'io.UnsupportedOperation'>, UnsupportedOperation('fileno',),
<traceback object at 0x00000297BAF30B08>)
    scons: done building targets.

Best,
Franz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20180823/1de67f71/attachment.html>


More information about the Scons-users mailing list