Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Mailer.send() raises NameError: add_charset, charset_QP, Header and Encoders are not imported (1.20260805.0)

オープン 初心者向け
#1,069 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1〜3時間
初心者へのやさしさ
92/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

py4web/utils/mailer.py を開き、pyflakes が報告する未定義の名前 (add_charset、charset_QP、Header、Encoders) を確認します。Mailer.send() の例で失敗を再現し、通常のメッセージと添付ファイルの処理が NameError を発生させなくなったこと、および UTF-8 quoted-printable メッセージが正しく構築されることを検証します。

索引モデルが issue の本文から書いたものです。

説明

Description

In py4web 1.20260805.0 (the latest release on PyPI), and on current master, Mailer.send() raises NameError on every call, so no email can be sent. That includes the emails sent by Auth.

py4web/utils/mailer.py uses four names that it never imports:

Line Name
391 add_charset
391 charset_QP
395 Header
235 Encoders (attachments only)

They used to come from from pydal._compat import *. Commit 1df05c3 ("last py4web version before the pydal refactor") removed that import without replacing those four names. pyflakes py4web/utils/mailer.py reports them as undefined.

Steps to reproduce

from py4web.utils.mailer import Mailer

m = Mailer(server="logging", sender="[email protected]")
m.send("[email protected]", "subject", "body")

Actual result

  File ".../py4web/utils/mailer.py", line 391, in send
    add_charset("utf-8", charset_QP, charset_QP, "utf-8")
    ^^^^^^^^^^^
NameError: name 'add_charset' is not defined

Suggested fix

Add the missing imports to py4web/utils/mailer.py:

from email import encoders as Encoders
from email.charset import QP as charset_QP
from email.charset import add_charset
from email.header import Header

I am working around it at the application level by injecting these names into py4web.utils.mailer. With that in place, send() builds a correct quoted-printable UTF-8 message and hands it to SMTP.

Environment

  • py4web 1.20260805.0
  • pydal 20260520.0
  • Python 3.12 (Linux and Google App Engine)
主要言語
HTML
スター
319
フォーク
144
平均マージ
1分
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

web2py/py4web のほかの issue

web2py/py4web の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。