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
c8079017
Commit
c8079017
authored
May 19, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #12112: packaging reads/writes metadata using UTF-8
parent
8818c7be
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
9 deletions
+9
-9
Lib/packaging/metadata.py
Lib/packaging/metadata.py
+2
-2
Lib/packaging/tests/test_dist.py
Lib/packaging/tests/test_dist.py
+1
-1
Lib/packaging/tests/test_metadata.py
Lib/packaging/tests/test_metadata.py
+6
-6
No files found.
Lib/packaging/metadata.py
View file @
c8079017
...
@@ -307,7 +307,7 @@ class Metadata:
...
@@ -307,7 +307,7 @@ class Metadata:
def
read
(
self
,
filepath
):
def
read
(
self
,
filepath
):
"""Read the metadata values from a file path."""
"""Read the metadata values from a file path."""
with
open
(
filepath
,
'r'
,
encoding
=
'
ascii
'
)
as
fp
:
with
open
(
filepath
,
'r'
,
encoding
=
'
utf-8
'
)
as
fp
:
self
.
read_file
(
fp
)
self
.
read_file
(
fp
)
def
read_file
(
self
,
fileob
):
def
read_file
(
self
,
fileob
):
...
@@ -330,7 +330,7 @@ class Metadata:
...
@@ -330,7 +330,7 @@ class Metadata:
def
write
(
self
,
filepath
):
def
write
(
self
,
filepath
):
"""Write the metadata fields to filepath."""
"""Write the metadata fields to filepath."""
with
open
(
filepath
,
'w'
)
as
fp
:
with
open
(
filepath
,
'w'
,
encoding
=
'utf-8'
)
as
fp
:
self
.
write_file
(
fp
)
self
.
write_file
(
fp
)
def
write_file
(
self
,
fileobject
):
def
write_file
(
self
,
fileobject
):
...
...
Lib/packaging/tests/test_dist.py
View file @
c8079017
...
@@ -78,7 +78,7 @@ class DistributionTestCase(support.TempdirManager,
...
@@ -78,7 +78,7 @@ class DistributionTestCase(support.TempdirManager,
# let's make sure the file can be written
# let's make sure the file can be written
# with Unicode fields. they are encoded with
# with Unicode fields. they are encoded with
# PKG_INFO_ENCODING
# PKG_INFO_ENCODING
with
open
(
my_file
,
'w'
)
as
fp
:
with
open
(
my_file
,
'w'
,
encoding
=
'utf-8'
)
as
fp
:
dist
.
metadata
.
write_file
(
fp
)
dist
.
metadata
.
write_file
(
fp
)
# regular ascii is of course always usable
# regular ascii is of course always usable
...
...
Lib/packaging/tests/test_metadata.py
View file @
c8079017
...
@@ -17,7 +17,7 @@ class MetadataTestCase(LoggingCatcher,
...
@@ -17,7 +17,7 @@ class MetadataTestCase(LoggingCatcher,
def
test_instantiation
(
self
):
def
test_instantiation
(
self
):
PKG_INFO
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'PKG-INFO'
)
PKG_INFO
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'PKG-INFO'
)
with
open
(
PKG_INFO
,
'r'
)
as
f
:
with
open
(
PKG_INFO
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
contents
=
f
.
read
()
contents
=
f
.
read
()
fp
=
StringIO
(
contents
)
fp
=
StringIO
(
contents
)
...
@@ -57,7 +57,7 @@ class MetadataTestCase(LoggingCatcher,
...
@@ -57,7 +57,7 @@ class MetadataTestCase(LoggingCatcher,
def
test_metadata_markers
(
self
):
def
test_metadata_markers
(
self
):
# see if we can be platform-aware
# see if we can be platform-aware
PKG_INFO
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'PKG-INFO'
)
PKG_INFO
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'PKG-INFO'
)
with
open
(
PKG_INFO
,
'r'
)
as
f
:
with
open
(
PKG_INFO
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
content
=
f
.
read
()
%
sys
.
platform
content
=
f
.
read
()
%
sys
.
platform
metadata
=
Metadata
(
platform_dependent
=
True
)
metadata
=
Metadata
(
platform_dependent
=
True
)
...
@@ -77,7 +77,7 @@ class MetadataTestCase(LoggingCatcher,
...
@@ -77,7 +77,7 @@ class MetadataTestCase(LoggingCatcher,
def
test_description
(
self
):
def
test_description
(
self
):
PKG_INFO
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'PKG-INFO'
)
PKG_INFO
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'PKG-INFO'
)
with
open
(
PKG_INFO
,
'r'
)
as
f
:
with
open
(
PKG_INFO
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
content
=
f
.
read
()
%
sys
.
platform
content
=
f
.
read
()
%
sys
.
platform
metadata
=
Metadata
()
metadata
=
Metadata
()
metadata
.
read_file
(
StringIO
(
content
))
metadata
.
read_file
(
StringIO
(
content
))
...
@@ -97,7 +97,7 @@ class MetadataTestCase(LoggingCatcher,
...
@@ -97,7 +97,7 @@ class MetadataTestCase(LoggingCatcher,
def
test_mapping_api
(
self
):
def
test_mapping_api
(
self
):
PKG_INFO
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'PKG-INFO'
)
PKG_INFO
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'PKG-INFO'
)
with
open
(
PKG_INFO
,
'r'
)
as
f
:
with
open
(
PKG_INFO
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
content
=
f
.
read
()
%
sys
.
platform
content
=
f
.
read
()
%
sys
.
platform
metadata
=
Metadata
(
fileobj
=
StringIO
(
content
))
metadata
=
Metadata
(
fileobj
=
StringIO
(
content
))
self
.
assertIn
(
'Version'
,
metadata
.
keys
())
self
.
assertIn
(
'Version'
,
metadata
.
keys
())
...
@@ -130,14 +130,14 @@ class MetadataTestCase(LoggingCatcher,
...
@@ -130,14 +130,14 @@ class MetadataTestCase(LoggingCatcher,
PKG_INFO
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
PKG_INFO
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'SETUPTOOLS-PKG-INFO'
)
'SETUPTOOLS-PKG-INFO'
)
with
open
(
PKG_INFO
,
'r'
)
as
f
:
with
open
(
PKG_INFO
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
content
=
f
.
read
()
content
=
f
.
read
()
metadata
.
read_file
(
StringIO
(
content
))
metadata
.
read_file
(
StringIO
(
content
))
self
.
assertEqual
(
metadata
[
'Metadata-Version'
],
'1.0'
)
self
.
assertEqual
(
metadata
[
'Metadata-Version'
],
'1.0'
)
PKG_INFO
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
PKG_INFO
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'SETUPTOOLS-PKG-INFO2'
)
'SETUPTOOLS-PKG-INFO2'
)
with
open
(
PKG_INFO
,
'r'
)
as
f
:
with
open
(
PKG_INFO
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
content
=
f
.
read
()
content
=
f
.
read
()
metadata
.
read_file
(
StringIO
(
content
))
metadata
.
read_file
(
StringIO
(
content
))
self
.
assertEqual
(
metadata
[
'Metadata-Version'
],
'1.1'
)
self
.
assertEqual
(
metadata
[
'Metadata-Version'
],
'1.1'
)
...
...
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