Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Deprecation warning for non-integer number in gettext is not always accurate #110519

Copy link
Copy link
Closed
@serhiy-storchaka

Description

@serhiy-storchaka
Issue body actions

Bug report

gettext functions and methods that consider plural forms (like ngettext()) and directly or indirectly use GNUTranslations emit a deprecation warning if the number is not integer. But it only points to the line where GNUTranslations methods ngettext() or npgettext() are used directly. Since module level functions use it indirectly, and methods of other classes can use it indirectly as a fallback, the deprecation warning usually points to the line in the gettext module instead of the line in the user code that uses it. It makes deprecation warnings much less useful.

The following PR dynamically calculate the stacklevel for warning, skipping any gettext code.

Also I have found that many code is not covered by tests (in particular NullTranslations and domain-aware functions like dngettext()). The PR extends tests.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    Status

    Done
    Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.