Whole file
joke2k/faker
The author described this change as “fix: rebind deepcopy proxies to copied Faker instances (#2340)”. It counts as a record because the checks below fail on the code as it stood at 53314fc7d and pass on 01cb8d0f9, with nothing else changed between the two runs.
Projectjoke2k/faker
Fix saved2026-03-23
Sharing licenceMIT · LICENSE.txt
Change size+7 −5
What the code was meant to do, written into the code itself as a save note
fix: rebind deepcopy proxies to copied Faker instances (#2340)
The change
| 141 | 141 | def __deepcopy__(self, memodict): | |
| 142 | 142 | cls = self.__class__ | |
| 143 | 143 | result = cls.__new__(cls) | |
| 144 | - | result._locales = copy.deepcopy(self._locales) | |
| 145 | - | result._factories = copy.deepcopy(self._factories) | |
| 146 | - | result._factory_map = copy.deepcopy(self._factory_map) | |
| 147 | - | result._weights = copy.deepcopy(self._weights) | |
| 148 | - | result._unique_proxy = UniqueProxy(self) | |
| 144 | + | memodict[id(self)] = result | |
| 145 | + | result._locales = copy.deepcopy(self._locales, memodict) | |
| 146 | + | result._factory_map = copy.deepcopy(self._factory_map, memodict) | |
| 147 | + | result._factories = list(result._factory_map.values()) | |
| 148 | + | result._weights = copy.deepcopy(self._weights, memodict) | |
| 149 | + | result._unique_proxy = UniqueProxy(result) | |
| 149 | 150 | result._unique_proxy._seen = {k: {result._unique_proxy._sentinel} for k in self._unique_proxy._seen.keys()} | |
| 151 | + | result._optional_proxy = OptionalProxy(result) | |
| 150 | 152 | return result | |
| 151 | 153 | ||
| 152 | 154 | def __setstate__(self, state: Any) -> None: |
The check that tells the two apart
fail→pass·tests/test_proxy.py::TestFakerProxyClass::test_copy_rebinds_multiple_locale_proxies
fail→pass·tests/test_proxy.py::TestFakerProxyClass::test_copy_rebinds_single_locale_proxies
fail→pass·tests/test_proxy.py::TestFakerProxyClass::test_copy_unique_uses_copied_proxy_state
Check file tests/test_proxy.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it53314fc7d3fba03fed38bb1053a395fdfb50e35f
Broken version dated2026-03-13
Modulefaker.proxy
Units changedFaker
Fingerprint0db7f4a695e415c4
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.