Skip to content

Commit 9baaf89

Browse files
ngnpopefelixxm
authored andcommitted
Refs #34986 -- Added django.utils.version.PYPY.
1 parent 174369a commit 9baaf89

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

django/utils/version.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
from django.utils.regex_helper import _lazy_re_compile
88

9+
# Private, stable API for detecting the Python implementation.
10+
PYPY = sys.implementation.name == "pypy"
11+
912
# Private, stable API for detecting the Python version. PYXY means "Python X.Y
1013
# or later". So that third-party apps can use these values, each constant
1114
# should remain as long as the oldest supported Django version supports that

tests/dispatch/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import gc
2-
import sys
32
import weakref
43
from types import TracebackType
54

65
from django.dispatch import Signal, receiver
76
from django.test import SimpleTestCase
87
from django.test.utils import override_settings
8+
from django.utils.version import PYPY
99

10-
if hasattr(sys, "pypy_version_info"):
10+
if PYPY:
1111

1212
def garbage_collect():
1313
# Collecting weakreferences can take two collections on PyPy.

tests/runtests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from django.test.utils import NullTimeKeeper, TimeKeeper, get_runner
3131
from django.utils.deprecation import RemovedInDjango60Warning
3232
from django.utils.log import DEFAULT_LOGGING
33-
from django.utils.version import PY312
33+
from django.utils.version import PY312, PYPY
3434

3535
try:
3636
import MySQLdb
@@ -52,7 +52,7 @@
5252
# references, which are a minority, so the garbage collection threshold can be
5353
# larger than the default threshold of 700 allocations + deallocations without
5454
# much increase in memory usage.
55-
if not hasattr(sys, "pypy_version_info"):
55+
if not PYPY:
5656
gc.set_threshold(100_000)
5757

5858
RUNTESTS_DIR = os.path.abspath(os.path.dirname(__file__))

0 commit comments

Comments
 (0)