Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

further skip BufferedRandomType if does not exist #645

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions dill/_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
HAS_CTYPES = False
IS_PYPY = False

IS_PYODIDE = sys.platform == 'emscripten'

# helper objects
class _class:
def _method(self):
Expand Down Expand Up @@ -250,13 +252,15 @@ class _Struct(ctypes.Structure):
a['SliceType'] = slice(1)
a['UnboundMethodType'] = _class._method #XXX: works when not imported!
d['TextWrapperType'] = open(os.devnull, 'r') # same as mode='w','w+','r+'
d['BufferedRandomType'] = open(os.devnull, 'r+b') # same as mode='w+b'
if not IS_PYODIDE:
d['BufferedRandomType'] = open(os.devnull, 'r+b') # same as mode='w+b'
d['BufferedReaderType'] = open(os.devnull, 'rb') # (default: buffering=-1)
d['BufferedWriterType'] = open(os.devnull, 'wb')
try: # oddities: deprecated
from _pyio import open as _open
d['PyTextWrapperType'] = _open(os.devnull, 'r', buffering=-1)
d['PyBufferedRandomType'] = _open(os.devnull, 'r+b', buffering=-1)
if not IS_PYODIDE:
d['PyBufferedRandomType'] = _open(os.devnull, 'r+b', buffering=-1)
d['PyBufferedReaderType'] = _open(os.devnull, 'rb', buffering=-1)
d['PyBufferedWriterType'] = _open(os.devnull, 'wb', buffering=-1)
except ImportError:
Expand Down
3 changes: 2 additions & 1 deletion dill/tests/test_selected.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def _method(self):
# some clean-up #FIXME: should happen internal to dill
objects['TemporaryFileType'].close()
objects['TextWrapperType'].close()
objects['BufferedRandomType'].close()
if 'BufferedRandomType' in objects:
objects['BufferedRandomType'].close()
objects['BufferedReaderType'].close()
objects['BufferedWriterType'].close()
objects['FileType'].close()
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ tag_build = .dev0

[bdist_wheel]
#python-tag = py3
#plat-name = manylinux_2_24_x86_64
#plat-name = manylinux_2_28_x86_64

[sdist]
#formats=zip,gztar