Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c2aa09ad
Commit
c2aa09ad
authored
May 31, 2007
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have the sha module raise a DeprecationWarning as specified in PEP 4.
parent
03b75fa4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
7 deletions
+19
-7
Lib/sha.py
Lib/sha.py
+4
-0
Lib/test/test_hmac.py
Lib/test/test_hmac.py
+5
-5
Lib/test/test_pep247.py
Lib/test/test_pep247.py
+2
-0
Lib/test/test_sha.py
Lib/test/test_sha.py
+4
-0
Lib/uuid.py
Lib/uuid.py
+2
-2
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/sha.py
View file @
c2aa09ad
...
...
@@ -3,6 +3,10 @@
# Copyright (C) 2005 Gregory P. Smith (greg@electricrain.com)
# Licensed to PSF under a Contributor Agreement.
import
warnings
warnings
.
warn
(
"the sha module is deprecated; use the hashlib module instead"
,
DeprecationWarning
,
2
)
from
hashlib
import
sha1
as
sha
new
=
sha
...
...
Lib/test/test_hmac.py
View file @
c2aa09ad
import
hmac
import
sha
from
hashlib
import
sha1
import
unittest
from
test
import
test_support
...
...
@@ -43,7 +43,7 @@ class TestVectorsTestCase(unittest.TestCase):
def
test_sha_vectors
(
self
):
def
shatest
(
key
,
data
,
digest
):
h
=
hmac
.
HMAC
(
key
,
data
,
digestmod
=
sha
)
h
=
hmac
.
HMAC
(
key
,
data
,
digestmod
=
sha
1
)
self
.
assertEqual
(
h
.
hexdigest
().
upper
(),
digest
.
upper
())
shatest
(
chr
(
0x0b
)
*
20
,
...
...
@@ -95,11 +95,11 @@ class ConstructorTestCase(unittest.TestCase):
def
test_withmodule
(
self
):
# Constructor call with text and digest module.
import
sha
from
hashlib
import
sha1
try
:
h
=
hmac
.
HMAC
(
"key"
,
""
,
sha
)
h
=
hmac
.
HMAC
(
"key"
,
""
,
sha
1
)
except
:
self
.
fail
(
"Constructor call with
sha module
raised exception."
)
self
.
fail
(
"Constructor call with
hashlib.sha1
raised exception."
)
class
SanityTestCase
(
unittest
.
TestCase
):
...
...
Lib/test/test_pep247.py
View file @
c2aa09ad
...
...
@@ -6,6 +6,8 @@
import
warnings
warnings
.
filterwarnings
(
"ignore"
,
"the md5 module is deprecated.*"
,
DeprecationWarning
)
warnings
.
filterwarnings
(
"ignore"
,
"the sha module is deprecated.*"
,
DeprecationWarning
)
import
md5
,
sha
,
hmac
...
...
Lib/test/test_sha.py
View file @
c2aa09ad
...
...
@@ -4,6 +4,10 @@
# Publication 180-1, Secure Hash Standard, 1995 April 17
# http://www.itl.nist.gov/div897/pubs/fip180-1.htm
import
warnings
warnings
.
filterwarnings
(
"ignore"
,
"the sha module is deprecated.*"
,
DeprecationWarning
)
import
sha
import
unittest
from
test
import
test_support
...
...
Lib/uuid.py
View file @
c2aa09ad
...
...
@@ -529,8 +529,8 @@ def uuid4():
def
uuid5
(
namespace
,
name
):
"""Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
import
sha
hash
=
sha
.
sha
(
namespace
.
bytes
+
name
).
digest
()
from
hashlib
import
sha1
hash
=
sha
1
(
namespace
.
bytes
+
name
).
digest
()
return
UUID
(
bytes
=
hash
[:
16
],
version
=
5
)
# The following standard UUIDs are for use with uuid3() or uuid5().
...
...
Misc/NEWS
View file @
c2aa09ad
...
...
@@ -220,6 +220,8 @@ Core and builtins
Library
-------
- sha now raises a DeprecationWarning upon import.
- md5 now raises a DeprecationWarning upon import.
- mimify now raises a DeprecationWarning upon import.
...
...
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