Comments (7)
check pull request here: #34
from idna.
By applying this change, it means over a megabyte of data will need to be imported for each invocation for functionality that defaults to off and is likely not commonly used. The intent of having the import in the function is to only import the UTS 46 data if you are doing a UTS 46 conversion, and if you are only doing IDNA conversion you are not penalized. Given a number of patches I've received in the past are to do with reducing memory usage, I am hesitant to add a patch like this without further analysis.
Some quick numbers:
python -c 'import idna; idna.decode("xn--p1ai")'
Maximum resident set size (kbytes): 7608
python -c 'import idna; idna.decode("xn--p1ai", uts46=True)'
Maximum resident set size (kbytes): 9060
I am not sure I fully understand the use case around why this is a problem to begin with, but is there a patch that would address your issue and not require uts46data to be loaded unless you are using UTS46 functionality? (i.e. only import that data if uts46=True)
from idna.
Also, can you provide a reduction of the problem so it can be added as a unit test? There is no 'request' method in this library so presumably that is from somewhere else.
from idna.
It looks like he's calling requests and requests is calling idna. To be honest it sounds like his environment is broken if standard 'import's aren't working. He could presumably work around the problem by calling import idna.uts46data
at the start of his application so it's pre-loaded. A compromise solution might be to make that 'official' by adding a documented idna.load_data()
function or something?
from idna.
The issue was copied from requests library which uses idna (I edited the issue). I found this bug with the latest version of requests.
When using import hooks (PEP302 with python2) you can't import inside a method, that will result in an import error.
I moved the import outside the method and everything is working fine.
doing a import idna.uts46data
will work fine at the beginning of the file, however when the method is called uts46_remap the import error will be raised.
I will try to do an unit test to reproduce this issue
from idna.
This really sounds like a bug in your import hook rather than a bug in idna.
from idna.
@kjd since moving the import means over megabytes of data will need. I will close this one since I found a way to avoid using the uts46=True
.
from idna.
Related Issues (20)
- Found a bug in idna version 2.8:UnicodeEncodeError: 'ascii' codec can't encode character '\uff2a' in position 0: ordinal not in range(128) HOT 3
- Type error happened when join byte string.
- CI: Set minimum permissions on GitHub Workflow HOT 2
- Create a Security Policy
- Exception when decoding U+20AC Euro Sign HOT 1
- Function to check if a string is an idna domain HOT 3
- Suggest adoption of Scorecard GitHub Action HOT 1
- IDNA package source installation is broken in Poetry - Adhere to PEP-721 HOT 2
- Deprecate `setup.cfg` HOT 1
- Set a new minimum Python version HOT 2
- Use code formatter on source HOT 4
- PyPI Publish GitHub Action failing HOT 1
- `HISTORY.rst` no longer included in source distribution HOT 1
- RFE: is it possible to start making github releases?🤔 HOT 6
- License identifier is incorrect on released packages HOT 5
- Document exceptions HOT 2
- Exception ValueError: no such name
- Reproducer for CVE-2024-3651 HOT 7
- Patch for CVE-2024-3651, for v3.3 HOT 3
- Clarify that uts46=True is preprocessing only (and still enforces IDNA-2008 restrictions)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from idna.