GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-135001: Explicitly specify the encoding parameter value of `calendar.HTMLCalendar` as 'utf-8' by Wulian233 · Pull Request #135002 · python/cpython

gh-135001: Explicitly specify the encoding parameter value of calendar.HTMLCalendar as 'utf-8' #135002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
vstinner merged 7 commits into python:main from Wulian233:calendar
Jun 9, 2025

Uh oh!

There was an error while loading. Please reload this page.

Merged

gh-135001: Explicitly specify the encoding parameter value of calendar.HTMLCalendar as 'utf-8' #135002

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
7 commits
Select commit Hold shift + click to select a range
68bd800
Change the default *encoding* of `calendar.HTMLCalendar` to UTF-8
Wulian233 Jun 1, 2025
a232d70
fix
Wulian233 Jun 6, 2025
a0465f3
fix
Wulian233 Jun 6, 2025
f5da0b9
lint
Wulian233 Jun 6, 2025
dd69284
Merge branch 'main' into calendar
Wulian233 Jun 6, 2025
bf55ca4
Delete Misc/NEWS.d/next/Library/2025-06-06-09-20-46.gh-issue-135001.z…
Wulian233 Jun 6, 2025
5618fa0
Merge branch 'main' into calendar
vstinner Jun 9, 2025
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

2 changes: 1 addition & 1 deletion 2 Doc/library/calendar.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
3) specifies the number of months per row. *css* is the name for the
cascading style sheet to be used. :const:`None` can be passed if no style
sheet should be used. *encoding* specifies the encoding to be used for the
output (defaulting to the system default encoding).
output (defaulting to ``'utf-8'``).


.. method:: formatmonthname(theyear, themonth, withyear=True)
Expand Down
6 changes: 3 additions & 3 deletions 6 Lib/calendar.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def formatyearpage(self, theyear, width=3, css='calendar.css', encoding=None):
Return a formatted year as a complete HTML page.
"""
if encoding is None:
encoding = sys.getdefaultencoding()
encoding = 'utf-8'
v = []
a = v.append
a('<?xml version="1.0" encoding="%s"?>\n' % encoding)
Expand Down Expand Up @@ -846,7 +846,7 @@ def main(args=None):
parser.add_argument(
"-e", "--encoding",
default=None,
help="encoding to use for output"
help="encoding to use for output (default utf-8)"
Comment thread
Wulian233 marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

)
parser.add_argument(
"-t", "--type",
Expand Down Expand Up @@ -890,7 +890,7 @@ def main(args=None):
cal.setfirstweekday(options.first_weekday)
encoding = options.encoding
if encoding is None:
encoding = sys.getdefaultencoding()
encoding = 'utf-8'
optdict = dict(encoding=encoding, css=options.css)
write = sys.stdout.buffer.write
if options.year is None:
Expand Down
2 changes: 1 addition & 1 deletion 2 Lib/test/test_calendar.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def test_output_htmlcalendar_encoding_utf8(self):
self.check_htmlcalendar_encoding('utf-8', 'utf-8')
Comment thread
vstinner marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.


def test_output_htmlcalendar_encoding_default(self):
self.check_htmlcalendar_encoding(None, sys.getdefaultencoding())
self.check_htmlcalendar_encoding(None, 'utf-8')

def test_yeardatescalendar(self):
def shrink(cal):
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.