Skip to content

Commit 2210e4f

Browse files
authored
Import crc32c only if needed (#437)
1 parent e17b6a8 commit 2210e4f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Fixes
3636
- Fixed network monitor compatibility with Python 3.
3737
- Minor console GUI optimizations.
3838
- Fixed crash_threshold_element handling if blocks are used
39+
- `crc32c` is no longer a required package. Install manually if needed.
3940

4041
v0.1.6
4142
------

boofuzz/blocks/checksum.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
import zlib
55
from functools import wraps
66

7-
try:
8-
import crc32c # pytype: disable=import-error
9-
except ImportError:
10-
# Import guard for systems without crc32c support.
11-
warnings.warn("Importing crc32c package failed. Using crc32c checksums will fail.", UserWarning, stacklevel=2)
12-
crc32c = None
13-
pass
147
import six
158

169
from .. import exception, helpers, primitives
@@ -151,6 +144,13 @@ def _checksum(self, data, ipv4_src, ipv4_dst):
151144
check = struct.pack(self._endian + "L", (zlib.crc32(data) & 0xFFFFFFFF))
152145

153146
elif self._algorithm == "crc32c":
147+
try:
148+
import crc32c # pytype: disable=import-error
149+
except ImportError:
150+
warnings.warn(
151+
"Importing crc32c package failed. Please install it using pip.", UserWarning, stacklevel=2
152+
)
153+
raise
154154
check = struct.pack(self._endian + "L", crc32c.crc32(data))
155155

156156
elif self._algorithm == "adler32":

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def get_long_description():
5858
"backports.shutil_get_terminal_size",
5959
"click",
6060
"colorama",
61-
"crc32c",
6261
"Flask",
6362
"future",
6463
"impacket",

0 commit comments

Comments
 (0)