<commit_before>import ipaddress
import os
import pathlib
from copy import copy
from typing import List, TypeVar, Union, Optional

import six
import yaml

from .domain import Domain
from .encrypted_string import EncryptedString
from .get_my_ip import get_my_ipv4, get_my_ipv6
from .record import Record, RecordType

T = TypeVar('T')


def _getenvb(varname: str, value: T = None) -> Union[Optional[T], bytes]:
    res = os.getenv(varname, value)
    if res is value:
        return value
    return res.encode() if isinstance(res, str) else res


_getenvb = getattr(os, 'getenvb', _getenvb)


class Config(dict):
    def __init__(self, src="freenom.yml", **kwargs):
        super().__init__(**kwargs)
        if isinstance(src, pathlib.Path):
            src = str(src)
        self._records = None
        self._password: EncryptedString = EncryptedString(b"")
        self.reload(src)
        self.file = src
<commit_msg>Fix _getenvb on some platform<commit_after>import ipaddress
import os
import pathlib
from copy import copy
from typing import List, TypeVar, Union, Optional

import six
import yaml

from .domain import Domain
from .encrypted_string import EncryptedString
from .get_my_ip import get_my_ipv4, get_my_ipv6
from .record import Record, RecordType

T = TypeVar('T')

if hasattr(os, 'getenvb'):
    def _getenvb(varname: str, value: T = None) -> Union[Optional[T], bytes]:
        return os.getenvb(varname.encode(), value)
else:
    def _getenvb(varname: str, value: T = None) -> Union[Optional[T], bytes]:

        res = os.getenv(varname, value)
        if res is value:
            return value
        return res.encode() if isinstance(res, str) else res


class Config(dict):
    def __init__(self, src="freenom.yml", **kwargs):
        super().__init__(**kwargs)
        if isinstance(src, pathlib.Path):
            src = str(src)
        self._records = None
        self._password: EncryptedString = EncryptedString(b"")
        self.reload(src)
        self.file = src

{'fraction_non_alphanumeric': 0.10381143430290872, 'fraction_numerical': 0.0020060180541624875, 'mean_word_length': 3.3369565217391304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '3076341', 'n_tokens_mistral': 631, 'n_tokens_neox': 623, 'n_words': 193}