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
7870bdff
Commit
7870bdff
authored
May 23, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #6501: os.device_encoding() returns None on Windows if the application
has no console.
parent
a1ae533a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
10 deletions
+16
-10
Misc/NEWS
Misc/NEWS
+3
-0
Modules/posixmodule.c
Modules/posixmodule.c
+13
-10
No files found.
Misc/NEWS
View file @
7870bdff
...
@@ -153,6 +153,9 @@ Core and Builtins
...
@@ -153,6 +153,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #6501: os.device_encoding() returns None on Windows if the application
has no console.
- Issue #12132: Skip test_build_ext in case the xxmodule is not found.
- Issue #12132: Skip test_build_ext in case the xxmodule is not found.
- Issue #12105: Add O_CLOEXEC to the os module.
- Issue #12105: Add O_CLOEXEC to the os module.
...
...
Modules/posixmodule.c
View file @
7870bdff
...
@@ -8495,6 +8495,9 @@ static PyObject *
...
@@ -8495,6 +8495,9 @@ static PyObject *
device_encoding
(
PyObject
*
self
,
PyObject
*
args
)
device_encoding
(
PyObject
*
self
,
PyObject
*
args
)
{
{
int
fd
;
int
fd
;
#if defined(MS_WINDOWS) || defined(MS_WIN64)
UINT
cp
;
#endif
if
(
!
PyArg_ParseTuple
(
args
,
"i:device_encoding"
,
&
fd
))
if
(
!
PyArg_ParseTuple
(
args
,
"i:device_encoding"
,
&
fd
))
return
NULL
;
return
NULL
;
if
(
!
_PyVerify_fd
(
fd
)
||
!
isatty
(
fd
))
{
if
(
!
_PyVerify_fd
(
fd
)
||
!
isatty
(
fd
))
{
...
@@ -8502,16 +8505,16 @@ device_encoding(PyObject *self, PyObject *args)
...
@@ -8502,16 +8505,16 @@ device_encoding(PyObject *self, PyObject *args)
return
Py_None
;
return
Py_None
;
}
}
#if defined(MS_WINDOWS) || defined(MS_WIN64)
#if defined(MS_WINDOWS) || defined(MS_WIN64)
if
(
fd
==
0
)
{
if
(
fd
==
0
)
c
har
buf
[
100
]
;
c
p
=
GetConsoleCP
()
;
sprintf
(
buf
,
"cp%d"
,
GetConsoleCP
());
else
if
(
fd
==
1
||
fd
==
2
)
return
PyUnicode_FromString
(
buf
);
cp
=
GetConsoleOutputCP
(
);
}
else
if
(
fd
==
1
||
fd
==
2
)
{
cp
=
0
;
char
buf
[
100
];
/* GetConsoleCP() and GetConsoleOutputCP() return 0 if the application
sprintf
(
buf
,
"cp%d"
,
GetConsoleOutputCP
());
has no console */
return
PyUnicode_FromString
(
buf
);
if
(
cp
!=
0
)
}
return
PyUnicode_FromFormat
(
"cp%u"
,
(
unsigned
int
)
cp
);
#elif defined(CODESET)
#elif defined(CODESET)
{
{
char
*
codeset
=
nl_langinfo
(
CODESET
);
char
*
codeset
=
nl_langinfo
(
CODESET
);
...
...
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