Skip to content

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

Closed
@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 security fixes3.12only security fixestype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions