# Buggy code
def _ReplacePathsInCode(self, topLevelModule, co):
    """Replace paths in the code as directed, returning a new code object
    with the modified paths in place."""
    # Prepare the new filename.
    origFileName = newFileName = os.path.normpath(co.co_filename)
    for searchValue, replaceValue in self.replacePaths:
        if searchValue == "*":
            searchValue = os.path.dirname(topLevelModule.file)
            if topLevelModule.path:
                searchValue = os.path.dirname(searchValue)
            if searchValue:
                searchValue = searchValue + os.path.sep
        if not origFileName.startswith(searchValue):
            continue
        newFileName = replaceValue + origFileName[len(searchValue) :]
        break

    # Run on subordinate code objects from function & class definitions.
    constants = list(co.co_consts)
    for i, value in enumerate(constants):
        if isinstance(value, type(co)):
            constants[i] = self._ReplacePathsInCode(topLevelModule, value)

    # Build the new code object.
    return types.CodeType(
        co.co_argcount,
        co.co_kwonlyargcount,
        co.co_nlocals,
        co.co_stacksize,
        co.co_flags,
        co.co_code,
        tuple(constants),
        co.co_names,
        co.co_varnames,
        newFileName,
        co.co_name,
        co.co_firstlineno,
        co.co_lnotab,
        co.co_freevars,
        co.co_cellvars,
    )


# Traceback (TypeError)
Outputting to: build\exe.win-amd64-3.8
running build_exe
Traceback (most recent call last):
File "E:/ConParser/setup.py", line 110, in <module>
cx_Freeze.setup(
File "C:\Program Files\Python38\lib\site-packages\cx_Freeze\dist.py", line 348, in setup
distutils.core.setup(**attrs)
File "C:\Program Files\Python38\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Program Files\Python38\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Program Files\Python38\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Program Files\Python38\lib\site-packages\cx_Freeze\dist.py", line 219, in run
freezer.Freeze()
File "C:\Program Files\Python38\lib\site-packages\cx_Freeze\freezer.py", line 641, in Freeze
self.finder = self._GetModuleFinder()
File "C:\Program Files\Python38\lib\site-packages\cx_Freeze\freezer.py", line 362, in _GetModuleFinder
finder = cx_Freeze.ModuleFinder(self.includeFiles, self.excludes,
File "C:\Program Files\Python38\lib\site-packages\cx_Freeze\finder.py", line 141, in __init__
self._AddBaseModules()
File "C:\Program Files\Python38\lib\site-packages\cx_Freeze\finder.py", line 152, in _AddBaseModules
self.IncludeModule("traceback")
File "C:\Program Files\Python38\lib\site-packages\cx_Freeze\finder.py", line 616, in IncludeModule
module = self._ImportModule(name, deferredImports,
File "C:\Program Files\Python38\lib\site-packages\cx_Freeze\finder.py", line 296, in _ImportModule
module = self._InternalImportModule(name,
File "C:\Program Files\Python38\lib\site-packages\cx_Freeze\finder.py", line 389, in _InternalImportModule
module = self._LoadModule(name, fp, path, info, deferredImports,
File "C:\Program Files\Python38\lib\site-packages\cx_Freeze\finder.py", line 450, in _LoadModule
module.code = self._ReplacePathsInCode(topLevelModule,
File "C:\Program Files\Python38\lib\site-packages\cx_Freeze\finder.py", line 496, in _ReplacePathsInCode
constants[i] = self._ReplacePathsInCode(topLevelModule, value)
File "C:\Program Files\Python38\lib\site-packages\cx_Freeze\finder.py", line 499, in _ReplacePathsInCode
return types.CodeType(co.co_argcount, co.co_kwonlyargcount,
TypeError: an integer is required (got type bytes)

Process finished with exit code 1

# Fixed code
def _ReplacePathsInCode(self, topLevelModule, co):
    """Replace paths in the code as directed, returning a new code object
    with the modified paths in place."""
    # Prepare the new filename.
    origFileName = newFileName = os.path.normpath(co.co_filename)
    for searchValue, replaceValue in self.replacePaths:
        if searchValue == "*":
            searchValue = os.path.dirname(topLevelModule.file)
            if topLevelModule.path:
                searchValue = os.path.dirname(searchValue)
            if searchValue:
                searchValue = searchValue + os.path.sep
        if not origFileName.startswith(searchValue):
            continue
        newFileName = replaceValue + origFileName[len(searchValue) :]
        break

    # Run on subordinate code objects from function & class definitions.
    constants = list(co.co_consts)
    for i, value in enumerate(constants):
        if isinstance(value, type(co)):
            constants[i] = self._ReplacePathsInCode(topLevelModule, value)

    # Build the new code object.
    params = [
        co.co_argcount,
        co.co_kwonlyargcount,
        co.co_nlocals,
        co.co_stacksize,
        co.co_flags,
        co.co_code,
        tuple(constants),
        co.co_names,
        co.co_varnames,
        newFileName,
        co.co_name,
        co.co_firstlineno,
        co.co_lnotab,
        co.co_freevars,
        co.co_cellvars,
    ]
    if hasattr(co, "co_posonlyargcount"):
        # PEP570 added "positional only arguments" in Python 3.8
        params.insert(1, co.co_posonlyargcount)
    return types.CodeType(*params)