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

Remove compatibility with legacy versions of Python #64

Merged

Conversation

cclauss
Copy link
Collaborator

@cclauss cclauss commented Feb 10, 2024

Description

Please include:

  • relevant motivation
  • a summary of the change
  • which issue is fixed.
  • any additional dependencies that are required for this change.

Closes: # (issue)
Remove compatibility with legacy versions of Python
Remove src/whoosh/compat.py and then use Python 3 syntax.
Copy b(), memoryview_(), and u() into files that use them on variables to encourage future local refactoring.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation

@cclauss cclauss force-pushed the drop-legacy-versions-of-Python branch from cc89324 to 19846b2 Compare February 10, 2024 07:43
@cclauss cclauss force-pushed the drop-legacy-versions-of-Python branch from ab9c1c2 to daaaea4 Compare February 10, 2024 08:48
Copy link

sonarqubecloud bot commented Feb 10, 2024

Quality Gate Passed Quality Gate passed

Issues
48 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

codecov bot commented Feb 10, 2024

Codecov Report

Attention: 103 lines in your changes are missing coverage. Please review.

Comparison is base (14ab92f) 80.99% compared to head (daaaea4) 81.19%.

Files Patch % Lines
src/whoosh/formats.py 33.33% 6 Missing and 6 partials ⚠️
src/whoosh/automata/fsa.py 57.14% 9 Missing ⚠️
src/whoosh/lang/snowball/hungarian.py 30.76% 9 Missing ⚠️
src/whoosh/lang/snowball/portugese.py 20.00% 8 Missing ⚠️
src/whoosh/lang/snowball/finnish.py 36.36% 7 Missing ⚠️
src/whoosh/lang/snowball/french.py 30.00% 5 Missing and 2 partials ⚠️
src/whoosh/searching.py 28.57% 4 Missing and 1 partial ⚠️
src/whoosh/lang/snowball/spanish.py 33.33% 2 Missing and 2 partials ⚠️
src/whoosh/analysis/tokenizers.py 50.00% 3 Missing ⚠️
src/whoosh/fields.py 78.57% 1 Missing and 2 partials ⚠️
... and 25 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #64      +/-   ##
==========================================
+ Coverage   80.99%   81.19%   +0.20%     
==========================================
  Files         133      132       -1     
  Lines       29503    29299     -204     
  Branches     5066     5044      -22     
==========================================
- Hits        23895    23789     -106     
+ Misses       4735     4641      -94     
+ Partials      873      869       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cclauss
Copy link
Collaborator Author

cclauss commented Feb 10, 2024

CodeFactor is merely running ruff rule S301 and ruff rule S310
SonarCloud is merely running ruff rule S311 and flagging strings that start with http:// instead of https://.

% ruff --select=S --ignore=S101 # Will return a superset of the security issues raised by CodeFactor + SonarCloud.

% ruff rule S301

suspicious-pickle-usage (S301)

Derived from the flake8-bandit linter.

What it does

Checks for calls to pickle functions or modules that wrap them.

Why is this bad?

Deserializing untrusted data with pickle and other deserialization
modules is insecure as it can allow for the creation of arbitrary objects,
which can then be used to achieve arbitrary code execution and otherwise
unexpected behavior.

Avoid deserializing untrusted data with pickle and other deserialization
modules. Instead, consider safer formats, such as JSON.

If you must deserialize untrusted data with pickle, consider signing the
data with a secret key and verifying the signature before deserializing the
payload, This will prevent an attacker from injecting arbitrary objects
into the serialized data.

Example

import pickle

with open("foo.pickle", "rb") as file:
    foo = pickle.load(file)

Use instead:

import json

with open("foo.json", "rb") as file:
    foo = json.load(file)

References

@cclauss cclauss marked this pull request as ready for review February 10, 2024 09:33
@cclauss
Copy link
Collaborator Author

cclauss commented Feb 10, 2024

When this is released, please reduce README.md's
https://img.shields.io/pypi/pyversions/Whoosh-Reloaded -->
to match https://devguide.python.org/versions

@ZeroCool940711
Copy link
Contributor

When this is released, please reduce README.md's img.shields.io/pypi/pyversions/Whoosh-Reloaded --> to match devguide.python.org/versions

The list of supported Python versions on Pypi should be fixed when we do the next release. I will be doing a version increase to 3.0.0 after this is merged in an hour or so, since this PR and other changes we've done before will most likely bring breaking changes to projects using whoosh that want to migrate to whoosh-reloaded. I have not made any new release to only do a major version increase once and to not force too many changes too frequently.

@ZeroCool940711 ZeroCool940711 merged commit 6c32996 into Sygil-Dev:main Feb 10, 2024
13 of 14 checks passed
@cclauss cclauss deleted the drop-legacy-versions-of-Python branch February 10, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants