<commit_before>
#Note: Keep name-type-value-numchild-extra order

#return

import sys
import gdb
import base64
import __builtin__


# Fails on Windows.
try:
    import curses.ascii
    def printableChar(ucs):
        return select(curses.ascii.isprint(ucs), ucs, '?')
except:
    def printableChar(ucs):
        if ucs >= 32 and ucs <= 126:
            return ucs
        return '?'

# Fails on SimulatorQt.
try:
    import tempfile
    def createTempFile():
        file = tempfile.NamedTemporaryFile(prefix="gdbpy_")
        return file.name, file

    def removeTempFile(name, file):
        file.close()

except:
    fileCounter = 0
    def createTempFile():
        fileCounter += 1
        return "gdbpy_tmp%d" % fileCounter, None

    def removeTempFile(name, file):
        pass

verbosity = 0
verbosity = 1

# Some "Enums"

# Encodings

Unencoded8Bit, \
    Base64Encoded8BitWithQuotes, \
    Base64Encoded16BitWithQuotes, \
    Base64Encoded32BitWithQuotes, \
    Base64Encoded16Bit, \
    Base64Encoded8Bit, \
    Hex2EncodedLatin1, \
    Hex4EncodedLittleEndian, \
    Hex8EncodedLittleEndian, \
    Hex2EncodedUtf8, \
    Hex8EncodedBigEndian, \
    Hex4EncodedBigEndian \
        = range(12)

# Display modes
StopDisplay, DisplayImage1, DisplayString, DisplayImage, DisplayProcess = range(5)<commit_msg>Debugger/gdb: Fix Python temporary file creation Windows. Reviewed-by: hjk<commit_after>
#Note: Keep name-type-value-numchild-extra order

#return

import sys
import gdb
import base64
import __builtin__
import os

# Fails on Windows.
try:
    import curses.ascii
    def printableChar(ucs):
        return select(curses.ascii.isprint(ucs), ucs, '?')
except:
    def printableChar(ucs):
        if ucs >= 32 and ucs <= 126:
            return ucs
        return '?'

# Fails on SimulatorQt.
tempFileCounter = 0
try:
    import tempfile
#   Test if 2.6 is used (Windows), trigger exception and default
#   to 2nd version.
    tempfile.NamedTemporaryFile(prefix="gdbpy_",delete=True)
    def createTempFile():
        file = tempfile.NamedTemporaryFile(prefix="gdbpy_",delete=False)
        file.close()
        return file.name, file

except:
    def createTempFile():
        global tempFileCounter
        tempFileCounter += 1
        fileName = "%s/gdbpy_tmp_%d_%d" % (tempfile.gettempdir(), os.getpid(), tempFileCounter)
        return fileName, None

def removeTempFile(name, file):
    try:
        os.remove(name)
    except:
        pass

verbosity = 0
verbosity = 1

# Some "Enums"

# Encodings

Unencoded8Bit, \
    Base64Encoded8BitWithQuotes, \
    Base64Encoded16BitWithQuotes, \
    Base64Encoded32BitWithQuotes, \
    Base64Encoded16Bit, \
    Base64Encoded8Bit, \
    Hex2EncodedLatin1, \
    Hex4EncodedLittleEndian, \
    Hex8EncodedLittleEndian, \
    Hex2EncodedUtf8, \
    Hex8EncodedBigEndian, \
    Hex4EncodedBigEndian \
        = range(12)

# Display modes
StopDisplay, DisplayImage1, DisplayString, DisplayImage, DisplayProcess = range(5)
{'fraction_non_alphanumeric': 0.09164149043303121, 'fraction_numerical': 0.02920443101711984, 'mean_word_length': 3.037940379403794, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6120387', 'n_tokens_mistral': 1061, 'n_tokens_neox': 999, 'n_words': 223}