Skip to content

Commit 63a633d

Browse files
committed
Remove debug logging
1 parent ffbdc70 commit 63a633d

File tree

9 files changed

+38
-65
lines changed

9 files changed

+38
-65
lines changed

CHANGELOG.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,30 @@
22
Changelog
33
=========
44

5-
.. Pymunk 6.12?????
6-
Changes....
5+
Pymunk 6.11.1 (2025-02-09)
6+
--------------------------
7+
8+
**Python 3.13 GC issue fix**
9+
10+
This is a patch update to Pymunk that removes debug logging. This should an
11+
issue with GC on Python 3.13.
12+
13+
Changes:
14+
- Remove debug logging
15+
716

817
Pymunk 6.11.0 (2025-01-18)
918
--------------------------
1019

1120
**Debug draw for Pyglet 2.1**
1221

13-
This is a minor update to Pymunk that update the pyglet debug draw code to
22+
This is a minor update to Pymunk that update the Pyglet debug draw code to
1423
work with the newly released Pyglet 2.1. Note that this means Pyglet 2.0.x
1524
does not work anymore. The release also adds back pre-built wheels for Pypy
1625
with a workaround until Pypy make a new release.
1726

1827
Changes:
19-
- Support pyglet 2.1.x (this means Pyglet 2.0.x wont work)
28+
- Support Pyglet 2.1.x (this means Pyglet 2.0.x wont work)
2029
- Readded Pypy pre-built wheels
2130

2231

pymunk/_callbacks.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ def ext_cpBodyArbiterIteratorFunc(
299299
def ext_cpBodyConstraintIteratorFunc(
300300
cp_body: ffi.CData, cp_constraint: ffi.CData, _: ffi.CData
301301
) -> None:
302-
_logger.debug("bodyfree remove constraint %s %s", cp_body, cp_constraint)
303302
cp_space = lib.cpConstraintGetSpace(cp_constraint)
304303
if cp_space != ffi.NULL:
305304
lib.cpSpaceRemoveConstraint(cp_space, cp_constraint)
@@ -309,7 +308,6 @@ def ext_cpBodyConstraintIteratorFunc(
309308
def ext_cpBodyShapeIteratorFunc(
310309
cp_body: ffi.CData, cp_shape: ffi.CData, _: ffi.CData
311310
) -> None:
312-
_logger.debug("bodyfree remove shape %s %s", cp_body, cp_shape)
313311
cp_space = lib.cpShapeGetSpace(cp_shape)
314312
if cp_space != ffi.NULL:
315313
lib.cpSpaceRemoveShape(cp_space, cp_shape)

pymunk/body.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
__docformat__ = "reStructuredText"
22

3-
import logging
43
from typing import ( # Literal,
54
TYPE_CHECKING,
65
Any,
@@ -31,8 +30,6 @@
3130
_PositionFunc = Callable[["Body", float], None]
3231
_VelocityFunc = Callable[["Body", Vec2d, float, float], None]
3332

34-
_logger = logging.getLogger(__name__)
35-
3633

3734
class Body(PickleMixin, TypingAttrMixing, object):
3835
"""A rigid body
@@ -199,8 +196,6 @@ def __init__(
199196
"""
200197

201198
def freebody(cp_body: ffi.CData) -> None:
202-
_logger.debug("bodyfree start %s", cp_body)
203-
204199
# remove all shapes on this body from the space
205200
lib.cpBodyEachShape(cp_body, lib.ext_cpBodyShapeIteratorFunc, ffi.NULL)
206201

@@ -210,13 +205,9 @@ def freebody(cp_body: ffi.CData) -> None:
210205
)
211206

212207
cp_space = lib.cpBodyGetSpace(cp_body)
213-
_logger.debug("bodyfree space %s", cp_space)
214208
# print(cp_space, cp_space == ffi.NULL)
215209
if cp_space != ffi.NULL:
216-
_logger.debug("bodyfree space remove body %s %s", cp_space, cp_body)
217210
lib.cpSpaceRemoveBody(cp_space, cp_body)
218-
219-
_logger.debug("bodyfree free %s", cp_body)
220211
lib.cpBodyFree(cp_body)
221212

222213
if body_type == Body.DYNAMIC:

pymunk/constraints.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
"SimpleMotor",
6969
]
7070

71-
import logging
7271
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Union
7372

7473
if TYPE_CHECKING:
@@ -80,8 +79,6 @@
8079
from ._typing_attr import TypingAttrMixing
8180
from .vec2d import Vec2d
8281

83-
_logger = logging.getLogger(__name__)
84-
8582
_TorqueFunc = Callable[["DampedRotarySpring", float], float]
8683
_ForceFunc = Callable[["DampedSpring", float], float]
8784

@@ -114,7 +111,6 @@ def constraintfree(cp_constraint: ffi.CData) -> None:
114111
if cp_space != ffi.NULL:
115112
lib.cpSpaceRemoveConstraint(cp_space, cp_constraint)
116113

117-
_logger.debug("constraintfree %s", cp_constraint)
118114
lib.cpConstraintFree(cp_constraint)
119115

120116
self._constraint = ffi.gc(_constraint, constraintfree)
@@ -453,7 +449,7 @@ def __init__(
453449
b: "Body",
454450
*args: Union[
455451
Tuple[float, float], Tuple[Tuple[float, float], Tuple[float, float]]
456-
]
452+
],
457453
) -> None:
458454
"""a and b are the two bodies to connect, and pivot is the point in
459455
world coordinates of the pivot.

pymunk/shapes.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
__docformat__ = "reStructuredText"
22

3-
import logging
43
from typing import TYPE_CHECKING, List, Optional, Sequence, Tuple
54

65
if TYPE_CHECKING:
@@ -18,8 +17,6 @@
1817
from .transform import Transform
1918
from .vec2d import Vec2d
2019

21-
_logger = logging.getLogger(__name__)
22-
2320

2421
class Shape(PickleMixin, TypingAttrMixing, object):
2522
"""Base class for all the shapes.
@@ -59,19 +56,13 @@ def _init(self, body: Optional["Body"], _shape: ffi.CData) -> None:
5956
body._shapes.add(self)
6057

6158
def shapefree(cp_shape: ffi.CData) -> None:
62-
_logger.debug("shapefree start %s", cp_shape)
6359
cp_space = cp.cpShapeGetSpace(cp_shape)
6460
if cp_space != ffi.NULL:
65-
_logger.debug("shapefree remove from space %s %s", cp_space, cp_shape)
6661
cp.cpSpaceRemoveShape(cp_space, cp_shape)
6762

68-
_logger.debug("shapefree get body %s", cp_shape)
6963
cp_body = cp.cpShapeGetBody(cp_shape)
7064
if cp_body != ffi.NULL:
71-
_logger.debug("shapefree set body %s", cp_shape)
72-
# print(cp.cpShapeActive2(cp_shape))
7365
cp.cpShapeSetBody(cp_shape, ffi.NULL)
74-
_logger.debug("shapefree free %s", cp_shape)
7566
cp.cpShapeFree(cp_shape)
7667

7768
self._shape = ffi.gc(_shape, shapefree)

pymunk/space.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
__docformat__ = "reStructuredText"
22

3-
import logging
43
import platform
54
import weakref
65
from typing import (
@@ -39,8 +38,6 @@
3938

4039
_AddableObjects = Union[Body, Shape, Constraint]
4140

42-
_logger = logging.getLogger(__name__)
43-
4441

4542
class Space(PickleMixin, object):
4643
"""Spaces are the basic unit of simulation. You add rigid bodies, shapes
@@ -100,15 +97,12 @@ def __init__(self, threaded: bool = False) -> None:
10097
freefunc = cp.cpSpaceFree
10198

10299
def spacefree(cp_space: ffi.CData) -> None:
103-
_logger.debug("spacefree start %s", cp_space)
104-
105100
cp_shapes: List[Shape] = []
106101
cp_shapes_h = ffi.new_handle(cp_shapes)
107102
cp.cpSpaceEachShape(cp_space, lib.ext_cpSpaceShapeIteratorFunc, cp_shapes_h)
108103

109104
for cp_shape in cp_shapes:
110105
cp_space = lib.cpShapeGetSpace(cp_shape)
111-
_logger.debug("spacefree remove shape %s %s", cp_space, cp_shape)
112106

113107
lib.cpSpaceRemoveShape(cp_space, cp_shape)
114108
lib.cpShapeSetBody(cp_shape, ffi.NULL)
@@ -120,27 +114,22 @@ def spacefree(cp_space: ffi.CData) -> None:
120114
)
121115
for cp_constraint in cp_constraints:
122116
cp_space = lib.cpConstraintGetSpace(cp_constraint)
123-
_logger.debug(
124-
"spacefree remove constraint %s %s", cp_space, cp_constraint
125-
)
126117
lib.cpSpaceRemoveConstraint(cp_space, cp_constraint)
127118

128119
cp_bodys: List[Body] = []
129120
cp_bodys_h = ffi.new_handle(cp_bodys)
130121
cp.cpSpaceEachBody(cp_space, lib.ext_cpSpaceBodyIteratorFunc, cp_bodys_h)
131122
for cp_body in cp_bodys:
132123
cp_space = lib.cpBodyGetSpace(cp_body)
133-
_logger.debug("spacefree remove body %s %s", cp_space, cp_body)
134124
lib.cpSpaceRemoveBody(cp_space, cp_body)
135125

136-
_logger.debug("spacefree free %s", cp_space)
137126
freefunc(cp_space)
138127

139128
self._space = ffi.gc(cp_space, spacefree)
140129

141-
self._handlers: Dict[
142-
Any, CollisionHandler
143-
] = {} # To prevent the gc to collect the callbacks.
130+
self._handlers: Dict[Any, CollisionHandler] = (
131+
{}
132+
) # To prevent the gc to collect the callbacks.
144133

145134
self._post_step_callbacks: Dict[Any, Callable[["Space"], None]] = {}
146135
self._removed_shapes: Dict[int, Shape] = {}

pymunk/tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def run_tests(filter: str = "", with_dependencies: List[str] = []) -> bool:
6565
)
6666
except:
6767
pass
68-
print("")
68+
print()
6969

7070
def list_of_tests_gen(s: Any) -> Iterator[Any]:
7171
for test in s:

pymunk/tests/test_batch.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ def check_arb_data(arb: pymunk.Arbiter) -> None:
214214
# When using each_arbiter a mirror of each arbiter will be
215215
# returned as well. These we ignore.
216216
return
217-
# print(a_id, b_id, idx, arb.total_impulse)
218217
# Assert int values
219218
self.assertEqual(arb.is_first_contact, ints[idx * 4 + 2])
220219
self.assertEqual(len(arb.contact_point_set.points), ints[idx * 4 + 3])

pymunk/tests/test_common.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,28 +108,28 @@ def testNoStaticShape(self) -> None:
108108
b3.position = -9, 0
109109

110110
space.add(b1, c1, b2, c2, b3, c3)
111-
print("\nc1", c1)
111+
# print("\nc1", c1)
112112

113113
def remove_first(arbiter: p.Arbiter, space: p.Space, data: Any) -> None:
114-
print("SEP 1", arbiter.shapes)
115-
print(" space.shapes", space.shapes)
116-
print(" space._remove_later", space._remove_later)
114+
# print("SEP 1", arbiter.shapes)
115+
# print(" space.shapes", space.shapes)
116+
# print(" space._remove_later", space._remove_later)
117117
first_shape = arbiter.shapes[0]
118118
if c1 in space.shapes:
119119
space.remove(c1)
120-
print(" space.shapes", space.shapes)
121-
print(" space._remove_later", space._remove_later)
122-
print("SEP done")
120+
# print(" space.shapes", space.shapes)
121+
# print(" space._remove_later", space._remove_later)
122+
# print("SEP done")
123123
# space.add_post_step_callback(space.remove, first_shape, first_shape.body)
124124
# space.remove(c1)
125125

126126
space.add_collision_handler(2, 0).separate = remove_first
127-
print(1)
127+
# print(1)
128128
space.step(1.0 / 60)
129-
print(2)
129+
# print(2)
130130
b2.position = 22, 0
131131
space.step(1.0 / 60)
132-
print(3)
132+
# print(3)
133133

134134
def testX(self) -> None:
135135
space = p.Space()
@@ -149,24 +149,24 @@ def testX(self) -> None:
149149
# b3.position = -9, 0
150150

151151
space.add(b1, c1, b2, c2, b3, c3)
152-
print("\nc1", c1)
152+
# print("\nc1", c1)
153153

154154
def separate(arbiter: p.Arbiter, space: p.Space, data: Any) -> None:
155-
print("SEP 1", arbiter.shapes)
156-
print(" space.shapes", space.shapes)
157-
print(" space._remove_later", space._remove_later)
155+
# print("SEP 1", arbiter.shapes)
156+
# print(" space.shapes", space.shapes)
157+
# print(" space._remove_later", space._remove_later)
158158
if c1 in space.shapes:
159159
space.remove(c1)
160-
print(" space.shapes", space.shapes)
161-
print(" space._remove_later", space._remove_later)
162-
print("SEP done")
160+
# print(" space.shapes", space.shapes)
161+
# print(" space._remove_later", space._remove_later)
162+
# print("SEP done")
163163
# space.add_post_step_callback(space.remove, first_shape, first_shape.body)
164164
# space.remove(c1)
165165

166166
space.add_collision_handler(2, 0).separate = separate
167-
print(1)
167+
# print(1)
168168
space.step(1)
169-
print(2)
169+
# print(2)
170170
b2.position = 22, 0
171171
space.step(1)
172-
print(3)
172+
# print(3)

0 commit comments

Comments
 (0)