def patch_python_dll_winver(self, dll_name, new_winver = None):
        from py2exe.resources.StringTables import StringTable, RT_STRING
        from py2exe_util import add_resource, load_resource
        from py2exe.resources.VersionInfo import RT_VERSION

        new_winver = new_winver and self.distribution.metadata.name or "py2exe"
        if self.verbose:
            print "setting sys.winver for '%s' to '%s'" % (dll_name, new_winver)
        if self.dry_run:
            return

        # We preserve the times on the file, so the dependency tracker works.
        st = os.stat(dll_name)
        # and as the resource functions silently fail if the open fails,
        # check it explicitly.
        os.chmod(dll_name, stat.S_IREAD | stat.S_IWRITE)
        try:
            f = open(dll_name, "a+b")
            f.close()
        except IOError, why:
            print "WARNING: File %s could not be opened - %s" % (dll_name, why)
        # We aren't smart enough to update string resources in place, so we need
        # to persist other resources we care about.
        unicode_name = ensure_unicode(dll_name)

        # Preserve existing version info (all versions should have this)
        ver_info = load_resource(unicode_name, RT_VERSION, 1)
        # Preserve an existing manifest (only python26.dll+ will have this)
        try:
            # Manfiests have resource type of 24, and ID of either 1 or 2.
            mfest = load_resource(unicode_name, RT_MANIFEST, 2)
        except RuntimeError:
            mfest = None

        # Start putting the resources back, passing 'delete=True' for the first.
        add_resource(unicode_name, ver_info, RT_VERSION, 1, True)
        if mfest is not None:
            add_resource(unicode_name, mfest, RT_MANIFEST, 2, False)

        # OK - do the strings.
        s = StringTable()
        # 1000 is the resource ID Python loads for its winver.
        s.add_string(1000, new_winver)
        for id, data in s.binary():
            add_resource(ensure_unicode(dll_name), data, RT_STRING, id, False)

        # restore the time.
        os.utime(dll_name, (st[stat.ST_ATIME], st[stat.ST_MTIME]))
dataset/ETHPy150Open fogleman/FeedNotifier/patch/build_exe.py/py2exe.patch_python_dll_winver/operator `or` -> `and`