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
Merged
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
8 changes: 7 additions & 1 deletion 8 Lib/test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@ def test_or_type_operator_with_SpecialForm(self):
def test_or_type_repr(self):
assert repr(int | None) == "int | None"
assert repr(int | typing.GenericAlias(list, int)) == "int | list[int]"
assert repr(int | typing.TypeVar('T')) == "int | ~T"

def test_or_type_operator_with_genericalias(self):
a = list[int]
Expand Down Expand Up @@ -782,13 +783,18 @@ def __eq__(self, other):
issubclass(int, type_)

def test_or_type_operator_with_bad_module(self):
class TypeVar:
class BadMeta(type):
__qualname__ = 'TypeVar'
@property
def __module__(self):
1 / 0
TypeVar = BadMeta('TypeVar', (), {})
_SpecialForm = BadMeta('_SpecialForm', (), {})
# Crashes in Issue44483
with self.assertRaises(ZeroDivisionError):
str | TypeVar()
with self.assertRaises(ZeroDivisionError):
str | _SpecialForm()

@cpython_only
def test_or_type_operator_reference_cycle(self):
Expand Down
2 changes: 1 addition & 1 deletion 2 Objects/unionobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ is_typing_name(PyObject *obj, char *name)
if (strcmp(type->tp_name, name) != 0) {
return 0;
}
return is_typing_module(obj);
return is_typing_module((PyObject *)type);
}

static PyObject *
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.