Skip to content

[BUG] NameError: name 'unicode' is not defined #183

@WilliamHolmes

Description

@WilliamHolmes

When using detect-secrets in our Jenkins pipeline, we started to see this issue (only recently)...

pip install --upgrade "git+https://github.com/ibm/detect-secrets.git@master#egg=detect-secrets"

 detect-secrets scan --update .secrets.baseline
/home/jenkins/.local/lib/python3.12/site-packages/requests/__init__.py:113: RequestsDependencyWarning: urllib3 (2.6.3) or chardet (7.0.1)/charset_normalizer (3.4.4) doesn't match a supported version!
  warnings.warn(
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/detect_secrets/core/secrets_collection.py", line 411, in _extract_secrets_from_file
    plugin.analyze(
  File "/usr/local/lib/python3.12/site-packages/detect_secrets/plugins/base.py", line 131, in analyze
    file_lines = tuple(file.readlines())
                       ^^^^^^^^^^^^^^^^
  File "<frozen codecs>", line 715, in readlines
  File "<frozen codecs>", line 621, in readlines
  File "<frozen codecs>", line 507, in read
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 16: invalid continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/binaryornot/helpers.py", line 103, in is_binary_string
    bytes_to_check.decode(encoding=detected_encoding['encoding'])
TypeError: decode() argument 'encoding' must be str, not None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/detect-secrets", line 6, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/detect_secrets/main.py", line 57, in main
    baseline_dict = _perform_scan(
                    ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/detect_secrets/main.py", line 181, in _perform_scan
    new_baseline = baseline.initialize(
                   ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/detect_secrets/core/baseline.py", line 96, in initialize
    output.scan_file(file, suppress_unscannable_file_warnings)
  File "/usr/local/lib/python3.12/site-packages/detect_secrets/core/secrets_collection.py", line 260, in scan_file
    self._extract_secrets_from_file(
  File "/usr/local/lib/python3.12/site-packages/detect_secrets/core/secrets_collection.py", line 419, in _extract_secrets_from_file
    file_is_binary = is_binary(filename)
                     ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/binaryornot/check.py", line 33, in is_binary
    return is_binary_string(chunk)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/binaryornot/helpers.py", line 106, in is_binary_string
    unicode(bytes_to_check, encoding=detected_encoding['encoding'])  # noqa
    ^^^^^^^
NameError: name 'unicode' is not defined

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions