| 3867 | """ |
| 3868 | |
| 3869 | def __init__(self, prec=None, rounding=None, Emin=None, Emax=None, |
| 3870 | capitals=None, clamp=None, flags=None, traps=None, |
| 3871 | _ignored_flags=None): |
| 3872 | # Set defaults; for everything except flags and _ignored_flags, |
| 3873 | # inherit from DefaultContext. |
| 3874 | try: |
| 3875 | dc = DefaultContext |
| 3876 | except NameError: |
| 3877 | pass |
| 3878 | |
| 3879 | self.prec = prec if prec is not None else dc.prec |
| 3880 | self.rounding = rounding if rounding is not None else dc.rounding |
| 3881 | self.Emin = Emin if Emin is not None else dc.Emin |
| 3882 | self.Emax = Emax if Emax is not None else dc.Emax |
| 3883 | self.capitals = capitals if capitals is not None else dc.capitals |
| 3884 | self.clamp = clamp if clamp is not None else dc.clamp |
| 3885 | |
| 3886 | if _ignored_flags is None: |
| 3887 | self._ignored_flags = [] |
| 3888 | else: |
| 3889 | self._ignored_flags = _ignored_flags |
| 3890 | |
| 3891 | if traps is None: |
| 3892 | self.traps = dc.traps.copy() |
| 3893 | elif not isinstance(traps, dict): |
| 3894 | self.traps = dict((s, int(s in traps)) for s in _signals + traps) |
| 3895 | else: |
| 3896 | self.traps = traps |
| 3897 | |
| 3898 | if flags is None: |
| 3899 | self.flags = dict.fromkeys(_signals, 0) |
| 3900 | elif not isinstance(flags, dict): |
| 3901 | self.flags = dict((s, int(s in flags)) for s in _signals + flags) |
| 3902 | else: |
| 3903 | self.flags = flags |
| 3904 | |
| 3905 | def _set_integer_check(self, name, value, vmin, vmax): |
| 3906 | if not isinstance(value, int): |