| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -372,6 +372,8 @@ def test_module(self): | |||
| 372 | 372 | mod_generics_cache.__name__) | |
| 373 | 373 | self.assertEqual(mod_generics_cache.OldStyle.__module__, | |
| 374 | 374 | mod_generics_cache.__name__) | |
| 375 | + Alias.__module__ = "ham.spam.eggs" | ||
| 376 | + self.assertEqual(Alias.__module__, "ham.spam.eggs") | ||
| 375 | 377 | ||
| 376 | 378 | def test_unpack(self): | |
| 377 | 379 | type Alias = tuple[int, int] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Allow assignment to the ``__module__`` attribute of | ||
| 2 | + :class:`typing.TypeAliasType` instances. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1998,12 +1998,22 @@ typealias_module(PyObject *self, void *Py_UNUSED(closure)) | |||
| 1998 | 1998 | Py_RETURN_NONE; | |
| 1999 | 1999 | } | |
| 2000 | 2000 | ||
| 2001 | + static int | ||
| 2002 | + typealias_set_module(PyObject *self, PyObject *value, void *Py_UNUSED(closure)) | ||
| 2003 | + { | ||
| 2004 | + typealiasobject *ta = typealiasobject_CAST(self); | ||
| 2005 | + PyObject *old_module = ta->module; | ||
| 2006 | + Py_XDECREF(old_module); | ||
| 2007 | + ta->module = Py_XNewRef(value); | ||
| 2008 | + return 0; | ||
| 2009 | + } | ||
| 2010 | + | ||
| 2001 | 2011 | static PyGetSetDef typealias_getset[] = { | |
| 2002 | 2012 | {"__parameters__", typealias_parameters, NULL, NULL, NULL}, | |
| 2003 | 2013 | {"__type_params__", typealias_type_params, NULL, NULL, NULL}, | |
| 2004 | 2014 | {"__value__", typealias_value, NULL, NULL, NULL}, | |
| 2005 | 2015 | {"evaluate_value", typealias_evaluate_value, NULL, NULL, NULL}, | |
| 2006 | - {"__module__", typealias_module, NULL, NULL, NULL}, | ||
| 2016 | + {"__module__", typealias_module, typealias_set_module, NULL, NULL}, | ||
| 2007 | 2017 | {0} | |
| 2008 | 2018 | }; | |
| 2009 | 2019 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments