3434 cast ,
3535)
3636
37- from typing_extensions import Self
38-
3937try :
4038 import pydantic
4139 import pydantic_core
@@ -529,44 +527,6 @@ def with_child_unrestricted(self, *child_path: str) -> SandboxMatcher:
529527 }
530528)
531529
532- # sys.stdlib_module_names is only available on 3.10+, so we hardcode here. A
533- # test will fail if this list doesn't match the latest Python version it was
534- # generated against, spitting out the expected list. This is a string instead
535- # of a list of strings due to black wanting to format this to one item each
536- # line in a list.
537- _stdlib_module_names = (
538- "__future__,_abc,_aix_support,_ast,_asyncio,_bisect,_blake2,_bootsubprocess,_bz2,_codecs,"
539- "_codecs_cn,_codecs_hk,_codecs_iso2022,_codecs_jp,_codecs_kr,_codecs_tw,_collections,"
540- "_collections_abc,_compat_pickle,_compression,_contextvars,_crypt,_csv,_ctypes,_curses,"
541- "_curses_panel,_datetime,_dbm,_decimal,_elementtree,_frozen_importlib,_frozen_importlib_external,"
542- "_functools,_gdbm,_hashlib,_heapq,_imp,_io,_json,_locale,_lsprof,_lzma,_markupbase,"
543- "_md5,_msi,_multibytecodec,_multiprocessing,_opcode,_operator,_osx_support,_overlapped,"
544- "_pickle,_posixshmem,_posixsubprocess,_py_abc,_pydecimal,_pyio,_queue,_random,_scproxy,"
545- "_sha1,_sha256,_sha3,_sha512,_signal,_sitebuiltins,_socket,_sqlite3,_sre,_ssl,_stat,"
546- "_statistics,_string,_strptime,_struct,_symtable,_thread,_threading_local,_tkinter,"
547- "_tokenize,_tracemalloc,_typing,_uuid,_warnings,_weakref,_weakrefset,_winapi,_zoneinfo,"
548- "abc,aifc,antigravity,argparse,array,ast,asynchat,asyncio,asyncore,atexit,audioop,"
549- "base64,bdb,binascii,bisect,builtins,bz2,cProfile,calendar,cgi,cgitb,chunk,cmath,cmd,"
550- "code,codecs,codeop,collections,colorsys,compileall,concurrent,configparser,contextlib,"
551- "contextvars,copy,copyreg,crypt,csv,ctypes,curses,dataclasses,datetime,dbm,decimal,"
552- "difflib,dis,distutils,doctest,email,encodings,ensurepip,enum,errno,faulthandler,fcntl,"
553- "filecmp,fileinput,fnmatch,fractions,ftplib,functools,gc,genericpath,getopt,getpass,"
554- "gettext,glob,graphlib,grp,gzip,hashlib,heapq,hmac,html,http,idlelib,imaplib,imghdr,"
555- "imp,importlib,inspect,io,ipaddress,itertools,json,keyword,lib2to3,linecache,locale,"
556- "logging,lzma,mailbox,mailcap,marshal,math,mimetypes,mmap,modulefinder,msilib,msvcrt,"
557- "multiprocessing,netrc,nis,nntplib,nt,ntpath,nturl2path,numbers,opcode,operator,optparse,"
558- "os,ossaudiodev,pathlib,pdb,pickle,pickletools,pipes,pkgutil,platform,plistlib,poplib,"
559- "posix,posixpath,pprint,profile,pstats,pty,pwd,py_compile,pyclbr,pydoc,pydoc_data,"
560- "pyexpat,queue,quopri,random,re,readline,reprlib,resource,rlcompleter,runpy,sched,"
561- "secrets,select,selectors,shelve,shlex,shutil,signal,site,smtpd,smtplib,sndhdr,socket,"
562- "socketserver,spwd,sqlite3,sre_compile,sre_constants,sre_parse,ssl,stat,statistics,"
563- "string,stringprep,struct,subprocess,sunau,symtable,sys,sysconfig,syslog,tabnanny,"
564- "tarfile,telnetlib,tempfile,termios,textwrap,this,threading,time,timeit,tkinter,token,"
565- "tokenize,tomllib,trace,traceback,tracemalloc,tty,turtle,turtledemo,types,typing,unicodedata,"
566- "unittest,urllib,uu,uuid,venv,warnings,wave,weakref,webbrowser,winreg,winsound,wsgiref,"
567- "xdrlib,xml,xmlrpc,zipapp,zipfile,zipimport,zlib,zoneinfo"
568- )
569-
570530SandboxRestrictions .passthrough_modules_maximum = (
571531 SandboxRestrictions .passthrough_modules_with_temporal
572532 | {
@@ -575,7 +535,7 @@ def with_child_unrestricted(self, *child_path: str) -> SandboxMatcher:
575535 # manually setting sys.modules["os.path"]) they have certain child
576536 # expectations.
577537 v
578- for v in _stdlib_module_names . split ( "," )
538+ for v in sys . stdlib_module_names
579539 if v != "sys"
580540 }
581541)
0 commit comments