Faker adds path objects to sys.path_importer_cache, breaking other packages
See original GitHub issue- Faker version: 6.6.3
- OS: Gentoo Linux
After importing faker
, entries with PosixPath
objects are added as keys to sys.path_importer_cache
. However, the keys are supposed to be regular str
s there, and the wrong type breaks software relying on str
methods being available, e.g. astroid:
___________________________________________ ClassNodeTest.test_slots_added_dynamically_still_inferred ____________________________________________
self = <tests.unittest_scoped_nodes.ClassNodeTest testMethod=test_slots_added_dynamically_still_inferred>
def tearDown(self):
del sys.path[0]
datadir = find("")
for key in list(sys.path_importer_cache):
> if key.startswith(datadir):
E AttributeError: 'PosixPath' object has no attribute 'startswith'
tests/resources.py:41: AttributeError
Note that since Faker installs a pytest plugin, it is autoloaded by default in all programs’ test suites.
Steps to reproduce
import sys
import faker
print(sys.path_importer_cache)
Expected behavior
The printed dict should only contain str
keys.
Actual behavior
[...] PosixPath('/usr/lib/python3.9/site-packages/faker/providers/address'): FileFinder(PosixPath('/usr/lib/python3.9/site-packages/faker/providers/address')), PosixPath('/usr/lib/python3.9/site-packages/faker/providers/automotive'): FileFinder(PosixPath('/usr/lib/python3.9/site-packages/faker/providers/automotive')), [...]
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
The npm faker package and the unexpected demise of open ...
Liran Tal discusses real-world incidents that demonstrate how even the mightiest of open source projects can be defeated.
Read more >Dev corrupts NPM libs 'colors' and 'faker' breaking thousands ...
NPM has reverted to a previous version of the faker.js package and Github has suspended my access to all public and private projects....
Read more >Open source developer corrupts widely-used libraries ...
A developer appears to have purposefully corrupted a pair of open-source libraries on GitHub and software registry npm — “faker.js” and ...
Read more >Getting Started - Faker
Faker is a popular library that generates fake (but reasonable) data that can be used for things such as: Unit Testing; Performance Testing;...
Read more >How to Generate Fake Data in Node.js Using Faker.js
During system development and testing, employment of Fake data can be very useful. This is because it prevents one from using ones real ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@fcurella We’ve started seeing this issue today the first time without any code changes or upgrades on Faker. The only change was the upgrade from Python 3.8.9 to 3.8.10 after which this issue started to happen.
After looking into it, we were running Faker 6.6.3 which didn’t include the patch referenced by this issue. Pinning Faker to 8.1.2 fixed this for us on Python 3.8.10 (previously we didn’t have Faker pinned as we’re using it as a peer dependency of Factory Boy)