Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 675
    • Issues 675
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyPyPyPy
  • pypypypy
  • Issues
  • #3411
Closed
Open
Issue created Mar 06, 2021 by Matti Picus@mattipOwner

-Wonce does not seem to work correctly

There is a failing test around unittests that boils down to the difference between cpython and pypy on this code (save as /tmp/test.py)

#Run with -Wonce

import warnings


print('----------------------------')
warnings.warn(
    'warning warning',
    DeprecationWarning, 2)
warnings.warn(
    'warning warning',
    DeprecationWarning, 2)
warnings.warn(
    'warning warning',
    DeprecationWarning, 2)

def _deprecate(original_func):
    def deprecated_func(*args, **kwargs):
        warnings.warn(
            'Please use {0} instead.'.format(original_func.__name__),
            DeprecationWarning, 2)
        return original_func(*args, **kwargs)
    return deprecated_func

def func1():
    pass

func2 = _deprecate(func1)

print('----------------------------')

func2()
func2()
func2()
func2()

CPython3 -Wonce prints

----------------------------
sys:1: DeprecationWarning: warning warning
----------------------------
/tmp/test.py:32: DeprecationWarning: Please use func1 instead.
  func2()

PyPy 3.7 -Wonce print

----------------------------
sys:1: DeprecationWarning: warning warning
----------------------------
/tmp/stam.py:32: DeprecationWarning: Please use func1 instead.
  func2()
/tmp/stam.py:33: DeprecationWarning: Please use func1 instead.
  func2()
/tmp/stam.py:34: DeprecationWarning: Please use func1 instead.
  func2()
/tmp/stam.py:35: DeprecationWarning: Please use func1 instead.
  func2()

If I disable the built-in _warnings module the output is identical.

Edited Aug 29, 2021 by Matti Picus
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking