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
1d523e1a
Commit
1d523e1a
authored
Dec 19, 2009
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#7380: Fix some str/bytearray/bytes issues in uuid docs and implementation.
parent
e231e39c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
7 deletions
+13
-7
Doc/library/uuid.rst
Doc/library/uuid.rst
+4
-4
Lib/test/test_uuid.py
Lib/test/test_uuid.py
+6
-0
Lib/uuid.py
Lib/uuid.py
+3
-3
No files found.
Doc/library/uuid.rst
View file @
1d523e1a
...
...
@@ -31,9 +31,9 @@ random UUID.
UUID('{12345678-1234-5678-1234-567812345678}')
UUID('12345678123456781234567812345678')
UUID('urn:uuid:12345678-1234-5678-1234-567812345678')
UUID(bytes='\x12\x34\x56\x78'*4)
UUID(bytes_le='\x78\x56\x34\x12\x34\x12\x78\x56' +
'\x12\x34\x56\x78\x12\x34\x56\x78')
UUID(bytes=
b
'\x12\x34\x56\x78'*4)
UUID(bytes_le=
b
'\x78\x56\x34\x12\x34\x12\x78\x56' +
b
'\x12\x34\x56\x78\x12\x34\x56\x78')
UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678))
UUID(int=0x12345678123456781234567812345678)
...
...
@@ -247,7 +247,7 @@ Here are some examples of typical usage of the :mod:`uuid` module::
# get the raw 16 bytes of the UUID
>>> x.bytes
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f'
b
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f'
# make a UUID from a 16-byte string
>>> uuid.UUID(bytes=x.bytes)
...
...
Lib/test/test_uuid.py
View file @
1d523e1a
from
unittest
import
TestCase
from
test
import
support
import
builtins
import
uuid
def
importable
(
name
):
...
...
@@ -176,6 +177,11 @@ class TestUUID(TestCase):
for
u
in
equivalents
:
for
v
in
equivalents
:
equal
(
u
,
v
)
# Bug 7380: "bytes" and "bytes_le" should give the same type.
equal
(
type
(
u
.
bytes
),
builtins
.
bytes
)
equal
(
type
(
u
.
bytes_le
),
builtins
.
bytes
)
ascending
.
append
(
u
)
# Test comparison of UUIDs.
...
...
Lib/uuid.py
View file @
1d523e1a
...
...
@@ -13,7 +13,7 @@ Typical usage:
>>> import uuid
# make a UUID based on the host ID and current time
>>> uuid.uuid1()
>>> uuid.uuid1()
# doctest: +SKIP
UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')
# make a UUID using an MD5 hash of a namespace UUID and a name
...
...
@@ -21,7 +21,7 @@ Typical usage:
UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')
# make a random UUID
>>> uuid.uuid4()
>>> uuid.uuid4()
# doctest: +SKIP
UUID('16fd2706-8baf-433b-82eb-8c7fada847da')
# make a UUID using a SHA-1 hash of a namespace UUID and a name
...
...
@@ -237,7 +237,7 @@ class UUID(object):
bytes
=
bytearray
()
for
shift
in
range
(
0
,
128
,
8
):
bytes
.
insert
(
0
,
(
self
.
int
>>
shift
)
&
0xff
)
return
bytes
return
bytes
_
(
bytes
)
@
property
def
bytes_le
(
self
):
...
...
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