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
c29966f3
Commit
c29966f3
authored
Aug 10, 2011
by
Brian Curtin
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
0275fc19
5b0a4d22
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
4 deletions
+16
-4
Lib/calendar.py
Lib/calendar.py
+7
-4
Lib/test/test_calendar.py
Lib/test/test_calendar.py
+7
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/calendar.py
View file @
c29966f3
...
...
@@ -636,7 +636,7 @@ def main(args):
parser
.
add_option
(
"-e"
,
"--encoding"
,
dest
=
"encoding"
,
default
=
None
,
help
=
"Encoding to use for output"
help
=
"Encoding to use for output
.
"
)
parser
.
add_option
(
"-t"
,
"--type"
,
...
...
@@ -662,10 +662,11 @@ def main(args):
if
encoding
is
None
:
encoding
=
sys
.
getdefaultencoding
()
optdict
=
dict
(
encoding
=
encoding
,
css
=
options
.
css
)
write
=
sys
.
stdout
.
buffer
.
write
if
len
(
args
)
==
1
:
print
(
cal
.
formatyearpage
(
datetime
.
date
.
today
().
year
,
**
optdict
))
write
(
cal
.
formatyearpage
(
datetime
.
date
.
today
().
year
,
**
optdict
))
elif
len
(
args
)
==
2
:
print
(
cal
.
formatyearpage
(
int
(
args
[
1
]),
**
optdict
))
write
(
cal
.
formatyearpage
(
int
(
args
[
1
]),
**
optdict
))
else
:
parser
.
error
(
"incorrect number of arguments"
)
sys
.
exit
(
1
)
...
...
@@ -687,9 +688,11 @@ def main(args):
else
:
parser
.
error
(
"incorrect number of arguments"
)
sys
.
exit
(
1
)
write
=
sys
.
stdout
.
write
if
options
.
encoding
:
result
=
result
.
encode
(
options
.
encoding
)
print
(
result
)
write
=
sys
.
stdout
.
buffer
.
write
write
(
result
)
if
__name__
==
"__main__"
:
...
...
Lib/test/test_calendar.py
View file @
c29966f3
...
...
@@ -2,6 +2,7 @@ import calendar
import
unittest
from
test
import
support
from
test.script_helper
import
assert_python_ok
import
time
import
locale
...
...
@@ -451,6 +452,11 @@ class LeapdaysTestCase(unittest.TestCase):
self
.
assertEqual
(
calendar
.
leapdays
(
1997
,
2020
),
5
)
class
ConsoleOutputTestCase
(
unittest
.
TestCase
):
def
test_outputs_bytes
(
self
):
(
return_code
,
stdout
,
stderr
)
=
assert_python_ok
(
'-m'
,
'calendar'
,
'--type=html'
,
'2010'
)
self
.
assertEqual
(
stdout
[:
6
],
b'<?xml '
)
def
test_main
():
support
.
run_unittest
(
OutputTestCase
,
...
...
@@ -460,6 +466,7 @@ def test_main():
TimegmTestCase
,
MonthRangeTestCase
,
LeapdaysTestCase
,
ConsoleOutputTestCase
)
...
...
Misc/NEWS
View file @
c29966f3
...
...
@@ -251,6 +251,8 @@ Core and Builtins
Library
-------
- Issue #10087: Fix the html output format of the calendar module.
- Issue #12540: Prevent zombie IDLE processes on Windows due to changes
in os.kill().
...
...
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