Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
b17b0820
Unverified
Commit
b17b0820
authored
Jun 03, 2023
by
Bartosz Sokorski
Committed by
GitHub
Jun 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update hashlib usage (#8058)
parent
36153326
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
17 deletions
+0
-17
src/poetry/publishing/uploader.py
+0
-7
tests/utils/test_helpers.py
+0
-10
No files found.
src/poetry/publishing/uploader.py
View file @
b17b0820
...
@@ -27,8 +27,6 @@ if TYPE_CHECKING:
...
@@ -27,8 +27,6 @@ if TYPE_CHECKING:
from
poetry.poetry
import
Poetry
from
poetry.poetry
import
Poetry
_has_blake2
=
hasattr
(
hashlib
,
"blake2b"
)
class
UploadError
(
Exception
):
class
UploadError
(
Exception
):
def
__init__
(
self
,
error
:
ConnectionError
|
HTTPError
|
str
)
->
None
:
def
__init__
(
self
,
error
:
ConnectionError
|
HTTPError
|
str
)
->
None
:
...
@@ -115,7 +113,6 @@ class Uploader:
...
@@ -115,7 +113,6 @@ class Uploader:
file_type
=
self
.
_get_type
(
file
)
file_type
=
self
.
_get_type
(
file
)
if
_has_blake2
:
blake2_256_hash
=
hashlib
.
blake2b
(
digest_size
=
256
//
8
)
blake2_256_hash
=
hashlib
.
blake2b
(
digest_size
=
256
//
8
)
md5_hash
=
hashlib
.
md5
()
md5_hash
=
hashlib
.
md5
()
...
@@ -124,14 +121,10 @@ class Uploader:
...
@@ -124,14 +121,10 @@ class Uploader:
for
content
in
iter
(
lambda
:
fp
.
read
(
io
.
DEFAULT_BUFFER_SIZE
),
b
""
):
for
content
in
iter
(
lambda
:
fp
.
read
(
io
.
DEFAULT_BUFFER_SIZE
),
b
""
):
md5_hash
.
update
(
content
)
md5_hash
.
update
(
content
)
sha256_hash
.
update
(
content
)
sha256_hash
.
update
(
content
)
if
_has_blake2
:
blake2_256_hash
.
update
(
content
)
blake2_256_hash
.
update
(
content
)
md5_digest
=
md5_hash
.
hexdigest
()
md5_digest
=
md5_hash
.
hexdigest
()
sha2_digest
=
sha256_hash
.
hexdigest
()
sha2_digest
=
sha256_hash
.
hexdigest
()
blake2_256_digest
:
str
|
None
=
None
if
_has_blake2
:
blake2_256_digest
=
blake2_256_hash
.
hexdigest
()
blake2_256_digest
=
blake2_256_hash
.
hexdigest
()
py_version
:
str
|
None
=
None
py_version
:
str
|
None
=
None
...
...
tests/utils/test_helpers.py
View file @
b17b0820
...
@@ -74,17 +74,9 @@ def test_default_hash(fixture_dir: FixtureDirGetter) -> None:
...
@@ -74,17 +74,9 @@ def test_default_hash(fixture_dir: FixtureDirGetter) -> None:
assert
get_file_hash
(
fixture_dir
(
"distributions"
)
/
"demo-0.1.0.tar.gz"
)
==
sha_256
assert
get_file_hash
(
fixture_dir
(
"distributions"
)
/
"demo-0.1.0.tar.gz"
)
==
sha_256
try
:
from
hashlib
import
algorithms_guaranteed
except
ImportError
:
algorithms_guaranteed
=
{
"md5"
,
"sha1"
,
"sha224"
,
"sha256"
,
"sha384"
,
"sha512"
}
@pytest.mark.parametrize
(
@pytest.mark.parametrize
(
"hash_name,expected"
,
"hash_name,expected"
,
[
[
(
hash_name
,
value
)
for
hash_name
,
value
in
[
(
"sha224"
,
"d26bd24163fe91c16b4b0162e773514beab77b76114d9faf6a31e350"
),
(
"sha224"
,
"d26bd24163fe91c16b4b0162e773514beab77b76114d9faf6a31e350"
),
(
(
"sha3_512"
,
"sha3_512"
,
...
@@ -120,8 +112,6 @@ except ImportError:
...
@@ -120,8 +112,6 @@ except ImportError:
"sha3_256"
,
"sha3_256"
,
"7da5c08b416e6bcb339d6bedc0fe077c6e69af00607251ef4424c356ea061fcb"
,
"7da5c08b416e6bcb339d6bedc0fe077c6e69af00607251ef4424c356ea061fcb"
,
),
),
]
if
hash_name
in
algorithms_guaranteed
],
],
)
)
def
test_guaranteed_hash
(
def
test_guaranteed_hash
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment