diff options
-rw-r--r-- | contrib/pyzfs/libzfs_core/_error_translation.py | 14 | ||||
-rw-r--r-- | contrib/pyzfs/libzfs_core/_libzfs_core.py | 20 | ||||
-rw-r--r-- | contrib/pyzfs/libzfs_core/_nvlist.py | 8 | ||||
-rw-r--r-- | contrib/pyzfs/libzfs_core/ctypes.py | 4 |
4 files changed, 23 insertions, 23 deletions
diff --git a/contrib/pyzfs/libzfs_core/_error_translation.py b/contrib/pyzfs/libzfs_core/_error_translation.py index 98d3bb22a..b5f4bebce 100644 --- a/contrib/pyzfs/libzfs_core/_error_translation.py +++ b/contrib/pyzfs/libzfs_core/_error_translation.py @@ -732,7 +732,7 @@ def _pool_name(name): '@' separates a snapshot name from the rest of the dataset name. '#' separates a bookmark name from the rest of the dataset name. ''' - return re.split('[/@#]', name, 1)[0] + return re.split(b'[/@#]', name, 1)[0] def _fs_name(name): @@ -742,26 +742,26 @@ def _fs_name(name): '@' separates a snapshot name from the rest of the dataset name. '#' separates a bookmark name from the rest of the dataset name. ''' - return re.split('[@#]', name, 1)[0] + return re.split(b'[@#]', name, 1)[0] def _is_valid_name_component(component): - allowed = string.ascii_letters + string.digits + '-_.: ' - return component and all(x in allowed for x in component) + allowed = string.ascii_letters + string.digits + u'-_.: ' + return component and all(x in allowed.encode() for x in component) def _is_valid_fs_name(name): - return name and all(_is_valid_name_component(c) for c in name.split('/')) + return name and all(_is_valid_name_component(c) for c in name.split(b'/')) def _is_valid_snap_name(name): - parts = name.split('@') + parts = name.split(b'@') return (len(parts) == 2 and _is_valid_fs_name(parts[0]) and _is_valid_name_component(parts[1])) def _is_valid_bmark_name(name): - parts = name.split('#') + parts = name.split(b'#') return (len(parts) == 2 and _is_valid_fs_name(parts[0]) and _is_valid_name_component(parts[1])) diff --git a/contrib/pyzfs/libzfs_core/_libzfs_core.py b/contrib/pyzfs/libzfs_core/_libzfs_core.py index aa387dbb3..589926ba8 100644 --- a/contrib/pyzfs/libzfs_core/_libzfs_core.py +++ b/contrib/pyzfs/libzfs_core/_libzfs_core.py @@ -113,7 +113,7 @@ def lzc_create(name, ds_type='zfs', props=None, key=None): if props is None: props = {} if key is None: - key = bytes("") + key = b"" else: key = bytes(key) if ds_type == 'zfs': @@ -848,7 +848,7 @@ def lzc_change_key(fsname, crypt_cmd, props=None, key=None): if props is None: props = {} if key is None: - key = bytes("") + key = b"" else: key = bytes(key) cmd = { @@ -931,13 +931,13 @@ def lzc_channel_program( error. ''' output = {} - params_nv = nvlist_in({"argv": params}) + params_nv = nvlist_in({b"argv": params}) with nvlist_out(output) as outnvl: ret = _lib.lzc_channel_program( poolname, program, instrlimit, memlimit, params_nv, outnvl) errors.lzc_channel_program_translate_error( - ret, poolname, output.get("error")) - return output.get("return") + ret, poolname, output.get(b"error")) + return output.get(b"return") def lzc_channel_program_nosync( @@ -976,13 +976,13 @@ def lzc_channel_program_nosync( error. ''' output = {} - params_nv = nvlist_in({"argv": params}) + params_nv = nvlist_in({b"argv": params}) with nvlist_out(output) as outnvl: ret = _lib.lzc_channel_program_nosync( poolname, program, instrlimit, memlimit, params_nv, outnvl) errors.lzc_channel_program_translate_error( - ret, poolname, output.get("error")) - return output.get("return") + ret, poolname, output.get(b"error")) + return output.get(b"return") def lzc_receive_resumable( @@ -1406,7 +1406,7 @@ def lzc_receive_with_cmdprops( if cmdprops is None: cmdprops = {} if key is None: - key = bytes("") + key = b"" else: key = bytes(key) @@ -1511,7 +1511,7 @@ def lzc_sync(poolname, force=False): `innvl` has been replaced by the `force` boolean and `outnvl` has been conveniently removed since it's not used. ''' - innvl = nvlist_in({"force": force}) + innvl = nvlist_in({b"force": force}) with nvlist_out({}) as outnvl: ret = _lib.lzc_sync(poolname, innvl, outnvl) errors.lzc_sync_translate_error(ret, poolname) diff --git a/contrib/pyzfs/libzfs_core/_nvlist.py b/contrib/pyzfs/libzfs_core/_nvlist.py index d7451bfe3..fe4239a3c 100644 --- a/contrib/pyzfs/libzfs_core/_nvlist.py +++ b/contrib/pyzfs/libzfs_core/_nvlist.py @@ -160,10 +160,10 @@ def _type_info(typeid): # only integer properties need to be here _prop_name_to_type_str = { - "rewind-request": "uint32", - "type": "uint32", - "N_MORE_ERRORS": "int32", - "pool_context": "int32", + b"rewind-request": "uint32", + b"type": "uint32", + b"N_MORE_ERRORS": "int32", + b"pool_context": "int32", } diff --git a/contrib/pyzfs/libzfs_core/ctypes.py b/contrib/pyzfs/libzfs_core/ctypes.py index eab160219..d337f46ed 100644 --- a/contrib/pyzfs/libzfs_core/ctypes.py +++ b/contrib/pyzfs/libzfs_core/ctypes.py @@ -31,8 +31,8 @@ def _ffi_cast(type_name): try: type_info.elements[value] except KeyError as e: - raise OverflowError('Invalid enum <%s> value %s' % - (type_info.cname, e.message)) + raise OverflowError('Invalid enum <%s> value %s: %s' % + (type_info.cname, value, e)) else: _ffi.new(type_name + '*', value) return _ffi.cast(type_name, value) |