Issue26636
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2016-03-24 14:35 by nbr_alt, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (4) | |||
---|---|---|---|
msg262349 - (view) | Author: Denis (nbr_alt) | Date: 2016-03-24 14:35 | |
Looks like related to Issue23571 Probably same issue as in Django, but in other Python module. While compiling python-module-crypto: ===================================================================== ERROR: test_getStrongPrime_randfunc_bogus (Crypto.SelfTest.Util.test_number.FastmathTests) Test that when getStrongPrime is called, an exception is raised if randfunc returns something bogus. ---------------------------------------------------------------------- TypeError: randfunc must return a string of random bytes During handling of the above exception, another exception occurred: SystemError: PyEval_EvalFrameEx returned a result with an error set During handling of the above exception, another exception occurred: Traceback (most recent call last): File "build/lib.linux-i686-3.5/Crypto/SelfTest/Util/test_number.py", line 322, in test_getStrongPrime_randfunc_bogus self.assertRaises(TypeError, number._fastmath.getStrongPrime, 512, randfunc=randfunc) File "/usr/lib/python3.5/unittest/case.py", line 765, in assertRaises return context.handle('assertRaises', args, kwargs) File "/usr/lib/python3.5/unittest/case.py", line 214, in handle callable_obj(*args, **kwargs) SystemError: PyEval_EvalFrameEx returned a result with an error set ====================================================================== ERROR: test_getStrongPrime_randfunc_exception (Crypto.SelfTest.Util.test_number.FastmathTests) Test that when getStrongPrime is called, an exception raised in randfunc is propagated. ---------------------------------------------------------------------- Crypto.SelfTest.Util.test_number.MyError During handling of the above exception, another exception occurred: SystemError: <class 'Crypto.SelfTest.Util.test_number.MyError'> returned a result with an error set During handling of the above exception, another exception occurred: Traceback (most recent call last): File "build/lib.linux-i686-3.5/Crypto/SelfTest/Util/test_number.py", line 308, in test_getStrongPrime_randfunc_exception self.assertRaises(MyError, number._fastmath.getStrongPrime, 512, randfunc=randfunc) File "/usr/lib/python3.5/unittest/case.py", line 765, in assertRaises return context.handle('assertRaises', args, kwargs) File "/usr/lib/python3.5/unittest/case.py", line 214, in handle callable_obj(*args, **kwargs) File "build/lib.linux-i686-3.5/Crypto/SelfTest/Util/test_number.py", line 307, in randfunc raise MyError SystemError: <class 'Crypto.SelfTest.Util.test_number.MyError'> returned a result with an error set The file that cause that exception can be found at http://git.altlinux.org/gears/p/python-module-pycrypto.git?p=python-module-pycrypto.git;a=blob;f=lib/Crypto/SelfTest/Util/test_number.py;h=ac23e917b6e7d982a33fff0a14bec3e769500ba0;hb=86c4aa4683cd89f89c3d01a689efa525f961d340 |
|||
msg262359 - (view) | Author: STINNER Victor (vstinner) * | Date: 2016-03-24 15:27 | |
> Probably same issue as in Django, but in other Python module. Do you understand that bug very likely comes from your code? Please review the code of the Crypto module (especially number._fastmath.getStrongPrime) to ensure that it doesn't return a result with an exception set. If a function raises an exception, it must returns NULL. |
|||
msg262441 - (view) | Author: Denis (nbr_alt) | Date: 2016-03-25 14:12 | |
Thank you! The error was that some calls in pycrypto code were aggregated and exceptions in those calls were ignored. Here is the patch for pycrypto that fixed the build. @@ -1427,7 +1429,9 @@ getStrongPrime (PyObject *self, PyObject *args, PyObject *kwargs) Py_BLOCK_THREADS; res = 1; res &= getRandomRange (X, lower_bound, upper_bound, randfunc); + if (res!=0) res &= getRandomNBitInteger (y[0], 101, randfunc); + if (res!=0) res &= getRandomNBitInteger (y[1], 101, randfunc); Py_UNBLOCK_THREADS; ---- So this code tried to aggregate exceptions before propagating them, that was the reason for exception. |
|||
msg262442 - (view) | Author: STINNER Victor (vstinner) * | Date: 2016-03-25 14:15 | |
I hope that the exception will help you to write better software (don't loose exceptions) ;-) |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:58:28 | admin | set | github: 70823 |
2016-03-25 14:15:10 | vstinner | set | status: open -> closed messages: + msg262442 |
2016-03-25 14:12:20 | nbr_alt | set | resolution: not a bug messages: + msg262441 |
2016-03-24 15:27:21 | vstinner | set | messages: + msg262359 |
2016-03-24 14:47:49 | serhiy.storchaka | set | nosy:
+ vstinner |
2016-03-24 14:35:24 | nbr_alt | create |