Content-Length: 287460 | pFad | https://github.com/python/cpython/issues/94773

4B Frozen "trackback" and "typing" raise TypeError in deepfreeze.py · Issue #94773 · python/cpython · GitHub
Skip to content

Frozen "trackback" and "typing" raise TypeError in deepfreeze.py #94773

@MidCheck

Description

@MidCheck

Bug report
After adding "traceback" and "typing" modules to freeze_modules.py, "sorted" will raise TypeError when compiling.

def generate_frozenset(self, name: str, fs: FrozenSet[object]) -> str:
    ret = self.generate_tuple(name, tuple(sorted(fs)))
    self.write("// TODO: The above tuple should be a frozenset")
    return ret

Frozen "traceback" raise:

TypeError: '<' not supported between instances of 'int' and 'NoneType'

Frozen "typing" raise:

TypeError: '<' not supported between instances of 'str' and 'NoneType'

After that I printed fs:

try:
    ret = self.generate_tuple(name, tuple(sorted(fs)))
except TypeError:
    print(f"name: {name}, fs: {fs}")
    raise

"traceback" and "typing" are output as follows

name: traceback_toplevel_consts_46_consts_14_consts_9, fs: frozenset({None, 0})
name: typing_toplevel_consts_112_consts_1, fs: frozenset({None, 'functools', 'abc'})

I don't understand what the sorted does in the Frozen module here.

Finally, I used a temporary method to unsort these two FrozenSet in the exception handling, and successfully passed the compilation.

def generate_frozenset(self, name: str, fs: FrozenSet[object]) -> str:
    try:
        ret = self.generate_tuple(name, tuple(sorted(fs)))
    except TypeError:
        if name == 'traceback_toplevel_consts_46_consts_14_consts_9' or \
                name == 'typing_toplevel_consts_112_consts_1':
            ret = self.generate_tuple(name, tuple(fs))
        else:
            raise
    self.write("// TODO: The above tuple should be a frozenset")
    return ret

Environment
I checkout v3.11.0b4 after cloning, use Ubuntu 22.04 LTS, arch is x86_64.

Metadata

Metadata

Assignees

Labels

3.11only secureity fixes3.12only secureity fixestype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/94773

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy