<commit_before>
import os, sys, time
from hippy.phpcompiler import compile_php
from hippy.rpath import abspath

TIMEOUT = 1.0

class BytecodeCache(object):
    def __init__(self, timeout=TIMEOUT):
        self.cached_files = {}
        self.timeout = timeout

    # again, abs_filename is None for stdin
    def _really_compile(self, space, abs_fname):

        if abs_fname is None:
            f = os.fdopen(0) # open stdin
        else:
            f = open(abs_fname)

        data = f.read(-1)

        # probably don't want to close stdin
        if abs_fname is not None:
            f.close()

        if abs_fname is not None:
            tstamp = os.stat(abs_fname).st_mtime
        else:
            tstamp = time.time()

        bc = compile_php(abs_fname, data, space)
        self.cached_files[abs_fname] = (bc, tstamp)<commit_msg>Never put stdin in the bytecode cache.<commit_after>
import os, sys, time
from hippy.phpcompiler import compile_php
from hippy.rpath import abspath

TIMEOUT = 1.0

class BytecodeCache(object):
    def __init__(self, timeout=TIMEOUT):
        self.cached_files = {}
        self.timeout = timeout

    # again, abs_filename is None for stdin
    def _really_compile(self, space, abs_fname):

        if abs_fname is None:
            f = os.fdopen(0) # open stdin
        else:
            f = open(abs_fname)

        data = f.read(-1)

        bc = compile_php(abs_fname, data, space)

        if abs_fname is not None: # if not stdin, cache bytecode
            f.close() # also don't close if stdin
            tstamp = os.stat(abs_fname).st_mtime
            self.cached_files[abs_fname] = (bc, tstamp)

{'fraction_non_alphanumeric': 0.08777239709443099, 'fraction_numerical': 0.004842615012106538, 'mean_word_length': 2.2475442043222005, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5413031', 'n_tokens_mistral': 550, 'n_tokens_neox': 535, 'n_words': 151}