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
3ea9d149
Commit
3ea9d149
authored
Nov 12, 2007
by
Christian Heimes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for #1427: Error in standard module calendar
merge -r58935:58936 ../trunk
parent
22ae6d22
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
Lib/calendar.py
Lib/calendar.py
+12
-8
No files found.
Lib/calendar.py
View file @
3ea9d149
...
...
@@ -6,7 +6,9 @@ Sunday as the last (the European convention). Use setfirstweekday() to
set the first day of the week (0=Monday, 6=Sunday)."""
from
__future__
import
with_statement
import
sys
,
datetime
,
locale
import
sys
import
datetime
import
locale
as
_locale
__all__
=
[
"IllegalMonthError"
,
"IllegalWeekdayError"
,
"setfirstweekday"
,
"firstweekday"
,
"isleap"
,
"leapdays"
,
"weekday"
,
"monthrange"
,
...
...
@@ -485,11 +487,11 @@ class TimeEncoding:
self
.
locale
=
locale
def
__enter__
(
self
):
self
.
oldlocale
=
locale
.
setlocale
(
locale
.
LC_TIME
,
self
.
locale
)
return
locale
.
getlocale
(
locale
.
LC_TIME
)[
1
]
self
.
oldlocale
=
_locale
.
setlocale
(
_
locale
.
LC_TIME
,
self
.
locale
)
return
_locale
.
getlocale
(
_
locale
.
LC_TIME
)[
1
]
def
__exit__
(
self
,
*
args
):
locale
.
setlocale
(
locale
.
LC_TIME
,
self
.
oldlocale
)
_locale
.
setlocale
(
_
locale
.
LC_TIME
,
self
.
oldlocale
)
class
LocaleTextCalendar
(
TextCalendar
):
...
...
@@ -503,7 +505,7 @@ class LocaleTextCalendar(TextCalendar):
def
__init__
(
self
,
firstweekday
=
0
,
locale
=
None
):
TextCalendar
.
__init__
(
self
,
firstweekday
)
if
locale
is
None
:
locale
=
locale
.
getdefaultlocale
()
locale
=
_
locale
.
getdefaultlocale
()
self
.
locale
=
locale
def
formatweekday
(
self
,
day
,
width
):
...
...
@@ -537,7 +539,7 @@ class LocaleHTMLCalendar(HTMLCalendar):
def
__init__
(
self
,
firstweekday
=
0
,
locale
=
None
):
HTMLCalendar
.
__init__
(
self
,
firstweekday
)
if
locale
is
None
:
locale
=
locale
.
getdefaultlocale
()
locale
=
_
locale
.
getdefaultlocale
()
self
.
locale
=
locale
def
formatweekday
(
self
,
day
):
...
...
@@ -658,9 +660,11 @@ def main(args):
parser
.
error
(
"if --locale is specified --encoding is required"
)
sys
.
exit
(
1
)
locale
=
options
.
locale
,
options
.
encoding
if
options
.
type
==
"html"
:
if
options
.
locale
:
cal
=
LocaleHTMLCalendar
(
locale
=
options
.
locale
)
cal
=
LocaleHTMLCalendar
(
locale
=
locale
)
else
:
cal
=
HTMLCalendar
()
encoding
=
options
.
encoding
...
...
@@ -676,7 +680,7 @@ def main(args):
sys
.
exit
(
1
)
else
:
if
options
.
locale
:
cal
=
LocaleTextCalendar
(
locale
=
options
.
locale
)
cal
=
LocaleTextCalendar
(
locale
=
locale
)
else
:
cal
=
TextCalendar
()
optdict
=
dict
(
w
=
options
.
width
,
l
=
options
.
lines
)
...
...
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