question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 strs 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:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
levrikcommented, May 5, 2021

@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.

1reaction
mike-oakleycommented, May 6, 2021

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)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found