Skip to content

Commit

Permalink
lnotab and linetable: fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
leogama committed Jun 2, 2022
1 parent c027e39 commit 4d1db4a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions dill/_dill.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def _create_code(*args):
BYTES = (bytes, str)
BYTES_NONE = (bytes, str, type(None))
encode_bytes = lambda fields, patterns: {
key: val.encode() if pat == BYTES and isinstance(val, str) else val \
key: val.encode() if pat in (BYTES, BYTES_NONE) and isinstance(val, str) else val \
for (key, val), pat in zip(fields, patterns)
}

Expand Down Expand Up @@ -840,11 +840,9 @@ def _create_code(*args):

# Special case: lnotab and linetable
if CODE_VERSION >= (3,10):
if not LNOTAB: # came from <= 3.9
fields['linetable'] = b''
fields.setdefault('linetable', b'')
else:
if LNOTAB or 'exceptiontable' in fields: # came from >= 3.11 in the second case
fields['lnotab'] = LNOTAB
fields.setdefault('lnotab', LNOTAB)

args = (fields[param] for param in CODE_PARAMS)
return CodeType(*args)
Expand Down
4 changes: 2 additions & 2 deletions dill/_shims.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def _delattr(cell, name):
_setattr = Getattr(_dill, '_setattr', setattr)
_delattr = Getattr(_dill, '_delattr', delattr)

# Structural Patter Matching for reduce tuples.
# Structural Pattern Matching for reduce tuples.
@move_to(_dill)
class match:
"""
Expand Down Expand Up @@ -299,7 +299,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
def __getattr__(self, item):
return self.vars[item]
def case(self, *args, **kwargs):
"""just handles tuple patters"""
"""just handles tuple patterns"""
self.patterns = args + tuple(kwargs.values())
if len(self.value) != len(self.patterns):
return False
Expand Down

0 comments on commit 4d1db4a

Please sign in to comment.