better-dsh 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +49 -178
  2. package/cordis.patch.yml +4 -35
  3. package/docs/adr/0015-independent-bundles-agent-remote.md +40 -0
  4. package/docs/remote-tools.md +56 -0
  5. package/docs/specs/omp-python-repl-port/runtime-guide.md +33 -0
  6. package/docs/specs/omp-python-repl-port/spec.md +61 -0
  7. package/docs/specs/remote-tool-enhancement/spec.md +203 -0
  8. package/dsh-docs/baseline.md +13 -0
  9. package/dsh-docs/subsystems/invariants.md +3 -0
  10. package/dsh-docs/subsystems/invariants.zh.md +3 -0
  11. package/eval-description.md +7 -3
  12. package/lib/{LaunchOptions-kGXcZOe0.js → LaunchOptions-5eg7E0ye.js} +1 -1
  13. package/lib/LaunchOptions-DxQQ0s-A.js +4 -0
  14. package/lib/{bidi-BalpKaJc.js → bidi-CwabFH07.js} +1 -1
  15. package/lib/client/index.js +30 -6
  16. package/lib/failover/index.js +1 -1
  17. package/lib/fs-aware/sandbox-plugin.js +3 -3
  18. package/lib/{index-browser-CysrjMyM.js → index-browser-B-9jm12n.js} +4 -4
  19. package/lib/index.d.ts +17 -41
  20. package/lib/index.js +473 -1678
  21. package/lib/kernel-env-BOF0fNHn.js +91 -0
  22. package/lib/kernel-env.d.ts +4 -58
  23. package/lib/kernel-env.js +2 -2
  24. package/lib/{lsp-server-registry-BXvUTBY7.js → lsp-server-registry-BcdkHROD.js} +1 -1
  25. package/lib/{lsp-server-registry-CH9WNFFt.js → lsp-server-registry-D4VLs1Sm.js} +1 -1
  26. package/lib/{main-CupOhMp5.js → main-BeCgUd20.js} +8 -6
  27. package/lib/{main-BQeFrBM1.js → main-Dv_UQqG2.js} +1 -1
  28. package/lib/mobile/plugin.d.ts +1 -1
  29. package/lib/omp-python/DILL-LICENSE +35 -0
  30. package/lib/omp-python/OMP-LICENSE +23 -0
  31. package/lib/omp-python/better_snapshot.py +391 -0
  32. package/lib/omp-python/better_support.py +425 -0
  33. package/lib/omp-python/dill-provenance.json +55 -0
  34. package/lib/omp-python/provenance.json +13 -0
  35. package/lib/omp-python/runner.py +2499 -0
  36. package/lib/omp-python/vendor/dill/__diff.py +234 -0
  37. package/lib/omp-python/vendor/dill/__info__.py +291 -0
  38. package/lib/omp-python/vendor/dill/__init__.py +119 -0
  39. package/lib/omp-python/vendor/dill/_dill.py +2265 -0
  40. package/lib/omp-python/vendor/dill/_objects.py +545 -0
  41. package/lib/omp-python/vendor/dill/_shims.py +193 -0
  42. package/lib/omp-python/vendor/dill/detect.py +287 -0
  43. package/lib/omp-python/vendor/dill/logger.py +285 -0
  44. package/lib/omp-python/vendor/dill/objtypes.py +24 -0
  45. package/lib/omp-python/vendor/dill/pointers.py +122 -0
  46. package/lib/omp-python/vendor/dill/session.py +612 -0
  47. package/lib/omp-python/vendor/dill/settings.py +25 -0
  48. package/lib/omp-python/vendor/dill/source.py +1025 -0
  49. package/lib/omp-python/vendor/dill/temp.py +252 -0
  50. package/lib/{puppeteer-core-CSk2PtSm.js → puppeteer-core-Dnd7eqel.js} +9 -9
  51. package/lib/remote/plugin.d.ts +459 -5
  52. package/lib/remote/plugin.js +2389 -210
  53. package/lib/url-schemes/index.d.ts +11 -11
  54. package/lib/url-schemes/index.js +12 -12
  55. package/lib/web-password.d.ts +8 -8
  56. package/lib/web-password.js +5 -1
  57. package/lib/{web-trust-Dej_RI2B.d.ts → web-trust-CwZrTBcl.d.ts} +11 -11
  58. package/lib/web-trust.d.ts +1 -2
  59. package/lib/welcome-notice.d.ts +5 -7
  60. package/lib/welcome-notice.js +9 -48
  61. package/lib/{wrap-T4I0nfPM.js → wrap-0VA0uFx8.js} +1 -1
  62. package/package.json +6 -23
  63. package/scripts/kernel-provision.mjs +4 -34
  64. package/lib/LaunchOptions-B874eBu2.js +0 -4
  65. package/lib/bundle-delivery.d.ts +0 -20
  66. package/lib/bundle-delivery.js +0 -209
  67. package/lib/hmr.d.ts +0 -32
  68. package/lib/hmr.js +0 -49
  69. package/lib/kernel-bridge.py +0 -172
  70. package/lib/kernel-env-D8UOWeji.js +0 -195
  71. package/lib/webserver.d.ts +0 -10
  72. package/lib/webserver.js +0 -19
  73. package/scripts/register-bundle.mjs +0 -80
@@ -0,0 +1,545 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
4
+ # Copyright (c) 2008-2016 California Institute of Technology.
5
+ # Copyright (c) 2016-2026 The Uncertainty Quantification Foundation.
6
+ # License: 3-clause BSD. The full license text is available at:
7
+ # - https://github.com/uqfoundation/dill/blob/master/LICENSE
8
+ """
9
+ all Python Standard Library objects (currently: CH 1-15 @ 2.7)
10
+ and some other common objects (i.e. numpy.ndarray)
11
+ """
12
+
13
+ __all__ = ['registered','failures','succeeds']
14
+
15
+ # helper imports
16
+ import warnings; warnings.filterwarnings("ignore", category=DeprecationWarning)
17
+ import sys
18
+ import queue as Queue
19
+ #import dbm as anydbm #XXX: delete foo
20
+ from io import BytesIO as StringIO
21
+ import re
22
+ import array
23
+ import collections
24
+ import codecs
25
+ import struct
26
+ import dataclasses
27
+ import datetime
28
+ import calendar
29
+ import weakref
30
+ import pprint
31
+ import decimal
32
+ import numbers
33
+ import functools
34
+ import itertools
35
+ import operator
36
+ import tempfile
37
+ import shelve
38
+ import zlib
39
+ import gzip
40
+ import zipfile
41
+ import tarfile
42
+ import csv
43
+ import hashlib
44
+ import hmac
45
+ import os
46
+ import logging
47
+ import logging.handlers
48
+ import optparse
49
+ #import __hello__
50
+ import threading
51
+ import socket
52
+ import contextlib
53
+ import contextvars
54
+ try:
55
+ import bz2
56
+ import sqlite3
57
+ import dbm.ndbm as dbm
58
+ HAS_ALL = True
59
+ except ImportError: # Ubuntu
60
+ HAS_ALL = False
61
+ try:
62
+ #import curses
63
+ #from curses import textpad, panel
64
+ HAS_CURSES = True
65
+ except ImportError: # Windows
66
+ HAS_CURSES = False
67
+ try:
68
+ import ctypes
69
+ HAS_CTYPES = True
70
+ # if using `pypy`, pythonapi is not found
71
+ IS_PYPY = not hasattr(ctypes, 'pythonapi')
72
+ except ImportError: # MacPorts
73
+ HAS_CTYPES = False
74
+ IS_PYPY = False
75
+
76
+ IS_PYODIDE = sys.platform == 'emscripten'
77
+
78
+ # helper objects
79
+ class _class:
80
+ def _method(self):
81
+ pass
82
+ # @classmethod
83
+ # def _clsmethod(cls): #XXX: test me
84
+ # pass
85
+ # @staticmethod
86
+ # def _static(self): #XXX: test me
87
+ # pass
88
+ class _class2:
89
+ def __call__(self):
90
+ pass
91
+ _instance2 = _class2()
92
+ class _newclass(object):
93
+ def _method(self):
94
+ pass
95
+ # @classmethod
96
+ # def _clsmethod(cls): #XXX: test me
97
+ # pass
98
+ # @staticmethod
99
+ # def _static(self): #XXX: test me
100
+ # pass
101
+ class _newclass2(object):
102
+ __slots__ = ['descriptor']
103
+ def _function(x): yield x
104
+ def _function2():
105
+ try: raise
106
+ except Exception:
107
+ from sys import exc_info
108
+ e, er, tb = exc_info()
109
+ return er, tb
110
+ if HAS_CTYPES:
111
+ class _Struct(ctypes.Structure):
112
+ pass
113
+ _Struct._fields_ = [("_field", ctypes.c_int),("next", ctypes.POINTER(_Struct))]
114
+ _filedescrip, _tempfile = tempfile.mkstemp('r') # deleted in cleanup
115
+ if sys.hexversion < 0x30d00a1:
116
+ _tmpf = tempfile.TemporaryFile('w') # emits OSError 9 in python 3.13
117
+ else:
118
+ _tmpf = tempfile.NamedTemporaryFile('w').file # for > python 3.9
119
+
120
+ # objects used by dill for type declaration
121
+ registered = d = {}
122
+ # objects dill fails to pickle
123
+ failures = x = {}
124
+ # all other type objects
125
+ succeeds = a = {}
126
+
127
+ # types module (part of CH 8)
128
+ a['BooleanType'] = bool(1)
129
+ a['BuiltinFunctionType'] = len
130
+ a['BuiltinMethodType'] = a['BuiltinFunctionType']
131
+ a['BytesType'] = _bytes = codecs.latin_1_encode('\x00')[0] # bytes(1)
132
+ a['ClassType'] = _class
133
+ a['ComplexType'] = complex(1)
134
+ a['DictType'] = _dict = {}
135
+ a['DictionaryType'] = a['DictType']
136
+ a['FloatType'] = float(1)
137
+ a['FunctionType'] = _function
138
+ a['InstanceType'] = _instance = _class()
139
+ a['IntType'] = _int = int(1)
140
+ a['ListType'] = _list = []
141
+ a['NoneType'] = None
142
+ a['ObjectType'] = object()
143
+ a['StringType'] = _str = str(1)
144
+ a['TupleType'] = _tuple = ()
145
+ a['TypeType'] = type
146
+ a['LongType'] = _int
147
+ a['UnicodeType'] = _str
148
+ # built-in constants (CH 4)
149
+ a['CopyrightType'] = copyright
150
+ # built-in types (CH 5)
151
+ a['ClassObjectType'] = _newclass # <type 'type'>
152
+ a['ClassInstanceType'] = _newclass() # <type 'class'>
153
+ a['SetType'] = _set = set()
154
+ a['FrozenSetType'] = frozenset()
155
+ # built-in exceptions (CH 6)
156
+ a['ExceptionType'] = _exception = _function2()[0]
157
+ # string services (CH 7)
158
+ a['SREPatternType'] = _srepattern = re.compile('')
159
+ # data types (CH 8)
160
+ a['ArrayType'] = array.array("f")
161
+ a['DequeType'] = collections.deque([0])
162
+ a['DefaultDictType'] = collections.defaultdict(_function, _dict)
163
+ a['TZInfoType'] = datetime.tzinfo()
164
+ a['DateTimeType'] = datetime.datetime.today()
165
+ a['CalendarType'] = calendar.Calendar()
166
+ # numeric and mathematical types (CH 9)
167
+ a['DecimalType'] = decimal.Decimal(1)
168
+ # data compression and archiving (CH 12)
169
+ a['TarInfoType'] = tarfile.TarInfo()
170
+ # generic operating system services (CH 15)
171
+ a['LoggerType'] = _logger = logging.getLogger()
172
+ a['FormatterType'] = logging.Formatter() # pickle ok
173
+ a['FilterType'] = logging.Filter() # pickle ok
174
+ a['LogRecordType'] = logging.makeLogRecord(_dict) # pickle ok
175
+ a['OptionParserType'] = _oparser = optparse.OptionParser() # pickle ok
176
+ a['OptionGroupType'] = optparse.OptionGroup(_oparser,"foo") # pickle ok
177
+ a['OptionType'] = optparse.Option('--foo') # pickle ok
178
+ if HAS_CTYPES:
179
+ z = x if (IS_PYPY and sys.hexversion < 0x30b0df0) else a
180
+ z['CCharType'] = _cchar = ctypes.c_char()
181
+ z['CWCharType'] = ctypes.c_wchar() # fail == 2.6
182
+ z['CByteType'] = ctypes.c_byte()
183
+ z['CUByteType'] = ctypes.c_ubyte()
184
+ z['CShortType'] = ctypes.c_short()
185
+ z['CUShortType'] = ctypes.c_ushort()
186
+ z['CIntType'] = ctypes.c_int()
187
+ z['CUIntType'] = ctypes.c_uint()
188
+ z['CLongType'] = ctypes.c_long()
189
+ z['CULongType'] = ctypes.c_ulong()
190
+ z['CLongLongType'] = ctypes.c_longlong()
191
+ z['CULongLongType'] = ctypes.c_ulonglong()
192
+ z['CFloatType'] = ctypes.c_float()
193
+ z['CDoubleType'] = ctypes.c_double()
194
+ z['CSizeTType'] = ctypes.c_size_t()
195
+ del z
196
+ a['CLibraryLoaderType'] = ctypes.cdll
197
+ a['StructureType'] = _Struct
198
+ # if not IS_PYPY:
199
+ # a['BigEndianStructureType'] = ctypes.BigEndianStructure()
200
+ #NOTE: also LittleEndianStructureType and UnionType... abstract classes
201
+ #NOTE: remember for ctypesobj.contents creates a new python object
202
+ #NOTE: ctypes.c_int._objects is memberdescriptor for object's __dict__
203
+ #NOTE: base class of all ctypes data types is non-public _CData
204
+
205
+ import fractions
206
+ import io
207
+ from io import StringIO as TextIO
208
+ # built-in functions (CH 2)
209
+ a['ByteArrayType'] = bytearray([1])
210
+ # numeric and mathematical types (CH 9)
211
+ a['FractionType'] = fractions.Fraction()
212
+ a['NumberType'] = numbers.Number()
213
+ # generic operating system services (CH 15)
214
+ a['IOBaseType'] = io.IOBase()
215
+ a['RawIOBaseType'] = io.RawIOBase()
216
+ a['TextIOBaseType'] = io.TextIOBase()
217
+ a['BufferedIOBaseType'] = io.BufferedIOBase()
218
+ a['UnicodeIOType'] = TextIO() # the new StringIO
219
+ a['LoggerAdapterType'] = logging.LoggerAdapter(_logger,_dict) # pickle ok
220
+ if HAS_CTYPES:
221
+ z = x if (IS_PYPY and sys.hexversion < 0x30b0df0) else a
222
+ z['CBoolType'] = ctypes.c_bool(1)
223
+ z['CLongDoubleType'] = ctypes.c_longdouble()
224
+ del z
225
+ import argparse
226
+ # data types (CH 8)
227
+ a['OrderedDictType'] = collections.OrderedDict(_dict)
228
+ a['CounterType'] = collections.Counter(_dict)
229
+ if HAS_CTYPES:
230
+ z = x if (IS_PYPY and sys.hexversion < 0x30b0df0) else a
231
+ z['CSSizeTType'] = ctypes.c_ssize_t()
232
+ del z
233
+ # generic operating system services (CH 15)
234
+ a['NullHandlerType'] = logging.NullHandler() # pickle ok # new 2.7
235
+ a['ArgParseFileType'] = argparse.FileType() # pickle ok
236
+
237
+ # -- pickle fails on all below here -----------------------------------------
238
+ # types module (part of CH 8)
239
+ a['CodeType'] = compile('','','exec')
240
+ a['DictProxyType'] = type.__dict__
241
+ a['DictProxyType2'] = _newclass.__dict__
242
+ a['EllipsisType'] = Ellipsis
243
+ a['ClosedFileType'] = open(os.devnull, 'wb', buffering=0).close()
244
+ a['GetSetDescriptorType'] = array.array.typecode
245
+ a['LambdaType'] = _lambda = lambda x: lambda y: x #XXX: works when not imported!
246
+ a['MemberDescriptorType'] = _newclass2.descriptor
247
+ if not IS_PYPY:
248
+ a['MemberDescriptorType2'] = datetime.timedelta.days
249
+ a['MethodType'] = _method = _class()._method #XXX: works when not imported!
250
+ a['ModuleType'] = datetime
251
+ a['NotImplementedType'] = NotImplemented
252
+ a['SliceType'] = slice(1)
253
+ a['UnboundMethodType'] = _class._method #XXX: works when not imported!
254
+ from dill._dill import get_file_type as openfile
255
+ d['TextWrapperType'] = openfile('r', buffering=-1) # same as mode='w','w+','r+'
256
+ if not IS_PYODIDE:
257
+ d['BufferedRandomType'] = openfile('r+b', buffering=-1) # same as mode='w+b'
258
+ d['BufferedReaderType'] = openfile('rb', buffering=-1) # (default: buffering=-1)
259
+ d['BufferedWriterType'] = openfile('wb', buffering=-1)
260
+ try: # oddities: deprecated
261
+ from _pyio import open as _open
262
+ d['PyTextWrapperType'] = openfile('r', buffering=-1, open=_open)
263
+ if not IS_PYODIDE:
264
+ d['PyBufferedRandomType'] = openfile('r+b', buffering=-1, open=_open)
265
+ d['PyBufferedReaderType'] = openfile('rb', buffering=-1, open=_open)
266
+ d['PyBufferedWriterType'] = openfile('wb', buffering=-1, open=_open)
267
+ except ImportError:
268
+ pass
269
+ del openfile
270
+ # other (concrete) object types
271
+ z = d if sys.hexversion < 0x30800a2 else a
272
+ z['CellType'] = (_lambda)(0).__closure__[0]
273
+ del z
274
+ a['XRangeType'] = _xrange = range(1)
275
+ a['MethodDescriptorType'] = type.__dict__['mro']
276
+ a['WrapperDescriptorType'] = type.__repr__
277
+ #a['WrapperDescriptorType2'] = type.__dict__['__module__']#XXX: GetSetDescriptor
278
+ a['ClassMethodDescriptorType'] = type.__dict__['__prepare__']
279
+ # built-in functions (CH 2)
280
+ _methodwrap = (1).__lt__
281
+ a['MethodWrapperType'] = _methodwrap
282
+ a['StaticMethodType'] = staticmethod(_method)
283
+ a['ClassMethodType'] = classmethod(_method)
284
+ a['PropertyType'] = property()
285
+ d['SuperType'] = super(Exception, _exception)
286
+ # string services (CH 7)
287
+ _in = _bytes
288
+ a['InputType'] = _cstrI = StringIO(_in)
289
+ a['OutputType'] = _cstrO = StringIO()
290
+ # data types (CH 8)
291
+ a['WeakKeyDictionaryType'] = weakref.WeakKeyDictionary()
292
+ a['WeakValueDictionaryType'] = weakref.WeakValueDictionary()
293
+ a['ReferenceType'] = weakref.ref(_instance)
294
+ a['DeadReferenceType'] = weakref.ref(_class())
295
+ a['ProxyType'] = weakref.proxy(_instance)
296
+ a['DeadProxyType'] = weakref.proxy(_class())
297
+ a['CallableProxyType'] = weakref.proxy(_instance2)
298
+ a['DeadCallableProxyType'] = weakref.proxy(_class2())
299
+ a['QueueType'] = Queue.Queue()
300
+ # numeric and mathematical types (CH 9)
301
+ d['PartialType'] = functools.partial(int,base=2)
302
+ a['IzipType'] = zip('0','1')
303
+ d['ItemGetterType'] = operator.itemgetter(0)
304
+ d['AttrGetterType'] = operator.attrgetter('__repr__')
305
+ # file and directory access (CH 10)
306
+ _fileW = _cstrO
307
+ # data persistence (CH 11)
308
+ if HAS_ALL:
309
+ x['ConnectionType'] = _conn = sqlite3.connect(':memory:')
310
+ x['CursorType'] = _conn.cursor()
311
+ a['ShelveType'] = shelve.Shelf({})
312
+ # data compression and archiving (CH 12)
313
+ if HAS_ALL:
314
+ x['BZ2FileType'] = bz2.BZ2File(os.devnull)
315
+ x['BZ2CompressorType'] = bz2.BZ2Compressor()
316
+ x['BZ2DecompressorType'] = bz2.BZ2Decompressor()
317
+ #x['ZipFileType'] = _zip = zipfile.ZipFile(os.devnull,'w')
318
+ #_zip.write(_tempfile,'x') [causes annoying warning/error printed on import]
319
+ #a['ZipInfoType'] = _zip.getinfo('x')
320
+ a['TarFileType'] = tarfile.open(fileobj=_fileW,mode='w')
321
+ # file formats (CH 13)
322
+ x['DialectType'] = csv.get_dialect('excel')
323
+ if sys.hexversion < 0x30d00a1:
324
+ import xdrlib
325
+ a['PackerType'] = xdrlib.Packer()
326
+ # optional operating system services (CH 16)
327
+ a['LockType'] = threading.Lock()
328
+ a['RLockType'] = threading.RLock()
329
+ # generic operating system services (CH 15) # also closed/open and r/w/etc...
330
+ a['NamedLoggerType'] = _logger = logging.getLogger(__name__)
331
+ #a['FrozenModuleType'] = __hello__ #FIXME: prints "Hello world..."
332
+ # interprocess communication (CH 17)
333
+ x['SocketType'] = _socket = socket.socket()
334
+ x['SocketPairType'] = socket.socketpair()[0]
335
+ # python runtime services (CH 27)
336
+ a['GeneratorContextManagerType'] = contextlib.contextmanager(max)([1])
337
+ #a['ContextType'] = contextvars.Context() #XXX: ContextVar
338
+
339
+ try: # ipython
340
+ __IPYTHON__ is True # is ipython
341
+ except NameError:
342
+ # built-in constants (CH 4)
343
+ a['QuitterType'] = quit
344
+ d['ExitType'] = a['QuitterType']
345
+ try: # numpy #FIXME: slow... 0.05 to 0.1 sec to import numpy
346
+ from numpy import ufunc as _numpy_ufunc
347
+ from numpy import array as _numpy_array
348
+ from numpy import int32 as _numpy_int32
349
+ a['NumpyUfuncType'] = _numpy_ufunc
350
+ a['NumpyArrayType'] = _numpy_array
351
+ a['NumpyInt32Type'] = _numpy_int32
352
+ except ImportError:
353
+ pass
354
+ # generic operating system services (CH 15)
355
+ a['FileHandlerType'] = logging.FileHandler(os.devnull)
356
+ a['RotatingFileHandlerType'] = logging.handlers.RotatingFileHandler(os.devnull)
357
+ a['SocketHandlerType'] = logging.handlers.SocketHandler('localhost',514)
358
+ a['MemoryHandlerType'] = logging.handlers.MemoryHandler(1)
359
+ # data types (CH 8)
360
+ a['WeakSetType'] = weakref.WeakSet() # 2.7
361
+ # generic operating system services (CH 15) [errors when dill is imported]
362
+ #a['ArgumentParserType'] = _parser = argparse.ArgumentParser('PROG')
363
+ #a['NamespaceType'] = _parser.parse_args() # pickle ok
364
+ #a['SubParsersActionType'] = _parser.add_subparsers()
365
+ #a['MutuallyExclusiveGroupType'] = _parser.add_mutually_exclusive_group()
366
+ #a['ArgumentGroupType'] = _parser.add_argument_group()
367
+
368
+ # -- dill fails in some versions below here ---------------------------------
369
+ # types module (part of CH 8)
370
+ d['FileType'] = open(os.devnull, 'rb', buffering=0) # same 'wb','wb+','rb+'
371
+ # built-in functions (CH 2)
372
+ # Iterators:
373
+ a['ListIteratorType'] = iter(_list) # empty vs non-empty
374
+ a['SetIteratorType'] = iter(_set) #XXX: empty vs non-empty #FIXME: list_iterator
375
+ a['TupleIteratorType']= iter(_tuple) # empty vs non-empty
376
+ a['XRangeIteratorType'] = iter(_xrange) # empty vs non-empty
377
+ a["BytesIteratorType"] = iter(b'')
378
+ a["BytearrayIteratorType"] = iter(bytearray(b''))
379
+ z = x if IS_PYPY else a
380
+ z["CallableIteratorType"] = iter(iter, None)
381
+ del z
382
+ x["MemoryIteratorType"] = iter(memoryview(b''))
383
+ a["ListReverseiteratorType"] = reversed([])
384
+ X = a['OrderedDictType']
385
+ d["OdictKeysType"] = X.keys()
386
+ d["OdictValuesType"] = X.values()
387
+ d["OdictItemsType"] = X.items()
388
+ a["OdictIteratorType"] = iter(X.keys()) #FIXME: list_iterator
389
+ del X
390
+ #FIXME: list_iterator
391
+ a['DictionaryItemIteratorType'] = iter(type.__dict__.items())
392
+ a['DictionaryKeyIteratorType'] = iter(type.__dict__.keys())
393
+ a['DictionaryValueIteratorType'] = iter(type.__dict__.values())
394
+ if sys.hexversion >= 0x30800a0:
395
+ a["DictReversekeyiteratorType"] = reversed({}.keys())
396
+ a["DictReversevalueiteratorType"] = reversed({}.values())
397
+ a["DictReverseitemiteratorType"] = reversed({}.items())
398
+
399
+ try:
400
+ import symtable
401
+ #FIXME: fails to pickle
402
+ x["SymtableEntryType"] = symtable.symtable("", "string", "exec")._table
403
+ except ImportError:
404
+ pass
405
+
406
+ if sys.hexversion >= 0x30a00a0 and not IS_PYPY:
407
+ x['LineIteratorType'] = compile('3', '', 'eval').co_lines()
408
+
409
+ if sys.hexversion >= 0x30b00b0 and not IS_PYPY:
410
+ from types import GenericAlias
411
+ d["GenericAliasIteratorType"] = iter(GenericAlias(list, (int,)))
412
+ x['PositionsIteratorType'] = compile('3', '', 'eval').co_positions()
413
+
414
+ # data types (CH 8)
415
+ a['PrettyPrinterType'] = pprint.PrettyPrinter()
416
+ # file and directory access (CH 10)
417
+ a['TemporaryFileType'] = _tmpf
418
+ # data compression and archiving (CH 12)
419
+ x['GzipFileType'] = gzip.GzipFile(fileobj=_fileW)
420
+ # generic operating system services (CH 15)
421
+ a['StreamHandlerType'] = logging.StreamHandler()
422
+ # numeric and mathematical types (CH 9)
423
+ z = a if sys.hexversion < 0x30e00a1 else x
424
+ z['CountType'] = itertools.count(0) #FIXME: __reduce__ removed in 3.14.0a1
425
+ z['ChainType'] = itertools.chain('0','1')
426
+ z['ProductType'] = itertools.product('0','1')
427
+ z['CycleType'] = itertools.cycle('0')
428
+ z['PermutationsType'] = itertools.permutations('0')
429
+ z['CombinationsType'] = itertools.combinations('0',1)
430
+ z['RepeatType'] = itertools.repeat(0)
431
+ z['CompressType'] = itertools.compress('0',[1])
432
+ del z
433
+ #XXX: ...and etc
434
+
435
+ # -- dill fails on all below here -------------------------------------------
436
+ # types module (part of CH 8)
437
+ x['GeneratorType'] = _generator = _function(1) #XXX: priority
438
+ x['FrameType'] = _generator.gi_frame #XXX: inspect.currentframe()
439
+ x['TracebackType'] = _function2()[1] #(see: inspect.getouterframes,getframeinfo)
440
+ # other (concrete) object types
441
+ # (also: Capsule / CObject ?)
442
+ # built-in functions (CH 2)
443
+ # built-in types (CH 5)
444
+ # string services (CH 7)
445
+ x['StructType'] = struct.Struct('c')
446
+ x['CallableIteratorType'] = _srepattern.finditer('')
447
+ x['SREMatchType'] = _srepattern.match('')
448
+ x['SREScannerType'] = _srepattern.scanner('')
449
+ x['StreamReader'] = codecs.StreamReader(_cstrI) #XXX: ... and etc
450
+ # python object persistence (CH 11)
451
+ # x['DbShelveType'] = shelve.open('foo','n')#,protocol=2) #XXX: delete foo
452
+ if HAS_ALL:
453
+ z = a if IS_PYPY else x
454
+ z['DbmType'] = dbm.open(_tempfile,'n')
455
+ del z
456
+ # x['DbCursorType'] = _dbcursor = anydbm.open('foo','n') #XXX: delete foo
457
+ # x['DbType'] = _dbcursor.db
458
+ # data compression and archiving (CH 12)
459
+ x['ZlibCompressType'] = zlib.compressobj()
460
+ x['ZlibDecompressType'] = zlib.decompressobj()
461
+ # file formats (CH 13)
462
+ x['CSVReaderType'] = csv.reader(_cstrI)
463
+ x['CSVWriterType'] = csv.writer(_cstrO)
464
+ x['CSVDictReaderType'] = csv.DictReader(_cstrI)
465
+ x['CSVDictWriterType'] = csv.DictWriter(_cstrO,{})
466
+ # cryptographic services (CH 14)
467
+ x['HashType'] = hashlib.md5()
468
+ if (sys.hexversion < 0x30800a1):
469
+ x['HMACType'] = hmac.new(_in)
470
+ else:
471
+ x['HMACType'] = hmac.new(_in, digestmod='md5')
472
+ # generic operating system services (CH 15)
473
+ if HAS_CURSES: pass
474
+ #x['CursesWindowType'] = _curwin = curses.initscr() #FIXME: messes up tty
475
+ #x['CursesTextPadType'] = textpad.Textbox(_curwin)
476
+ #x['CursesPanelType'] = panel.new_panel(_curwin)
477
+ if HAS_CTYPES:
478
+ x['CCharPType'] = ctypes.c_char_p()
479
+ x['CWCharPType'] = ctypes.c_wchar_p()
480
+ x['CVoidPType'] = ctypes.c_void_p()
481
+ if sys.platform[:3] == 'win':
482
+ x['CDLLType'] = _cdll = ctypes.cdll.msvcrt
483
+ else:
484
+ x['CDLLType'] = _cdll = ctypes.CDLL(None)
485
+ if not IS_PYPY:
486
+ x['PyDLLType'] = _pydll = ctypes.pythonapi
487
+ x['FuncPtrType'] = _cdll._FuncPtr()
488
+ x['CCharArrayType'] = ctypes.create_string_buffer(1)
489
+ x['CWCharArrayType'] = ctypes.create_unicode_buffer(1)
490
+ x['CParamType'] = ctypes.byref(_cchar)
491
+ x['LPCCharType'] = ctypes.pointer(_cchar)
492
+ x['LPCCharObjType'] = _lpchar = ctypes.POINTER(ctypes.c_char)
493
+ x['NullPtrType'] = _lpchar()
494
+ x['NullPyObjectType'] = ctypes.py_object()
495
+ x['PyObjectType'] = ctypes.py_object(lambda :None)
496
+ z = a if IS_PYPY else x
497
+ z['FieldType'] = _field = _Struct._field
498
+ z['CFUNCTYPEType'] = _cfunc = ctypes.CFUNCTYPE(ctypes.c_char)
499
+ if sys.hexversion < 0x30c00b3:
500
+ x['CFunctionType'] = _cfunc(str)
501
+ del z
502
+ # numeric and mathematical types (CH 9)
503
+ a['MethodCallerType'] = operator.methodcaller('mro') # 2.6
504
+ # built-in types (CH 5)
505
+ x['MemoryType'] = memoryview(_in) # 2.7
506
+ x['MemoryType2'] = memoryview(bytearray(_in)) # 2.7
507
+ d['DictItemsType'] = _dict.items() # 2.7
508
+ d['DictKeysType'] = _dict.keys() # 2.7
509
+ d['DictValuesType'] = _dict.values() # 2.7
510
+ # generic operating system services (CH 15)
511
+ a['RawTextHelpFormatterType'] = argparse.RawTextHelpFormatter('PROG')
512
+ a['RawDescriptionHelpFormatterType'] = argparse.RawDescriptionHelpFormatter('PROG')
513
+ a['ArgDefaultsHelpFormatterType'] = argparse.ArgumentDefaultsHelpFormatter('PROG')
514
+ z = a if IS_PYPY else x
515
+ z['CmpKeyType'] = _cmpkey = functools.cmp_to_key(_methodwrap) # 2.7, >=3.2
516
+ z['CmpKeyObjType'] = _cmpkey('0') #2.7, >=3.2
517
+ del z
518
+ # oddities: removed, etc
519
+ x['BufferType'] = x['MemoryType']
520
+
521
+ from dill._dill import _testcapsule
522
+ if _testcapsule is not None:
523
+ d['PyCapsuleType'] = _testcapsule
524
+ del _testcapsule
525
+
526
+ if hasattr(dataclasses, '_HAS_DEFAULT_FACTORY'):
527
+ a['DataclassesHasDefaultFactoryType'] = dataclasses._HAS_DEFAULT_FACTORY
528
+
529
+ if hasattr(dataclasses, 'MISSING'):
530
+ a['DataclassesMissingType'] = dataclasses.MISSING
531
+
532
+ if hasattr(dataclasses, 'KW_ONLY'):
533
+ a['DataclassesKWOnlyType'] = dataclasses.KW_ONLY
534
+
535
+ if hasattr(dataclasses, '_FIELD_BASE'):
536
+ a['DataclassesFieldBaseType'] = dataclasses._FIELD
537
+
538
+ # -- cleanup ----------------------------------------------------------------
539
+ a.update(d) # registered also succeed
540
+ if sys.platform[:3] == 'win':
541
+ os.close(_filedescrip) # required on win32
542
+ os.remove(_tempfile)
543
+
544
+
545
+ # EOF