Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions pydantic-core/tests/validators/test_arguments.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import platform
import re
import sys
from functools import wraps
Expand Down Expand Up @@ -1139,9 +1138,6 @@ def test_invalid_schema():
)


@pytest.mark.xfail(
platform.python_implementation() == 'PyPy' and sys.version_info[:2] == (3, 11), reason='pypy 3.11 type formatting'
)
def test_error_display(pydantic_version):
v = SchemaValidator(
core_schema.arguments_schema(
Expand Down
4 changes: 0 additions & 4 deletions pydantic-core/tests/validators/test_definitions_recursive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import datetime
import platform
import sys
from dataclasses import dataclass
from typing import Optional

Expand Down Expand Up @@ -753,9 +752,6 @@ def test_many_uses_of_ref():
assert v.validate_python(long_input) == long_input


@pytest.mark.xfail(
platform.python_implementation() == 'PyPy' and sys.version_info[:2] == (3, 11), reason='pypy 3.11 type formatting'
)
def test_error_inside_definition_wrapper():
with pytest.raises(SchemaError) as exc_info:
SchemaValidator(
Expand Down
3 changes: 0 additions & 3 deletions pydantic-core/tests/validators/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,6 @@ def test_coerce_numbers_to_str_from_json(number: str, expected_str: str) -> None


@pytest.mark.parametrize('mode', (None, 'schema', 'config'))
@pytest.mark.xfail(
platform.python_implementation() == 'PyPy' and sys.version_info[:2] == (3, 11), reason='pypy 3.11 type formatting'
)
def test_backtracking_regex_rust_unsupported(mode) -> None:
pattern = r'r(#*)".*?"\1'

Expand Down
5 changes: 0 additions & 5 deletions pydantic-core/tests/validators/test_union.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import platform
import sys
from dataclasses import dataclass
from datetime import date, time
from enum import Enum, IntEnum
Expand Down Expand Up @@ -233,9 +231,6 @@ def test_union_list_bool_int():
]


@pytest.mark.xfail(
platform.python_implementation() == 'PyPy' and sys.version_info[:2] == (3, 11), reason='pypy 3.11 type formatting'
)
def test_empty_choices():
msg = r'Error building "union" validator:\s+SchemaError: One or more union choices required'
with pytest.raises(SchemaError, match=msg):
Expand Down
14 changes: 12 additions & 2 deletions pydantic/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,13 +831,23 @@ def _copy(self) -> Self:
# Fast-path if the instance isn't a subclass (`copy.copy()` relies on pickling which is slower):
copied = FieldInfo.__new__(FieldInfo)
for attr_name in FieldInfo.__slots__:
setattr(copied, attr_name, getattr(self, attr_name))
try:
value = getattr(self, attr_name)
except AttributeError:
# PyPy might have uninitialized slots
continue
setattr(copied, attr_name, value)
else:
copied = copy(self)

for attr_name in ('metadata', '_attributes_set', '_qualifiers'):
# Apply "deep-copy" behavior on collections attributes:
setattr(copied, attr_name, getattr(copied, attr_name).copy())
try:
value = getattr(copied, attr_name)
except AttributeError:
# PyPy might have uninitialized slots
continue
setattr(copied, attr_name, value.copy())

return copied # pyright: ignore[reportReturnType]

Expand Down
Loading