[tor-bugs] #11770 [Obfsproxy]: Print a warning if python-gmpy is not found

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue May 6 13:15:42 UTC 2014


#11770: Print a warning if python-gmpy is not found
---------------------------+-----------------
     Reporter:  asn        |      Owner:  asn
         Type:  defect     |     Status:  new
     Priority:  normal     |  Milestone:
    Component:  Obfsproxy  |    Version:
   Resolution:             |   Keywords:
Actual Points:             |  Parent ID:
       Points:             |
---------------------------+-----------------

Comment (by asn):

 {{{
 diff --git a/obfsproxy/common/modexp.py b/obfsproxy/common/modexp.py
 index 3f90ea8..b6a9784 100644
 --- a/obfsproxy/common/modexp.py
 +++ b/obfsproxy/common/modexp.py
 @@ -1,9 +1,19 @@
 +# Try to use gmpy to do modular exponentiations. It's faster and better.
 +# If gmpy cannot be found, fall back to the default Python pow()
 function.
  try:
      from gmpy2 import mpz as mpz
  except ImportError:
      try:
          from gmpy import mpz as mpz
      except ImportError:
 +
 +        # Log a warning so that the bridge operator installs gmpy.
 +        import obfsproxy.common.log as logging
 +        log = logging.get_obfslogger()
 +        log.warning("python-gmpy could not be found. Please consider
 installing it. " \
 +                    "Till then I will use Python's default modular
 exponentiation " \
 +                    "function which is slower and heavier.")
 +
          def mpz( x ):
              return x
          pass
 }}}

 FWIW, I tried the obvious patch above, but I think that the log file has
 not been set as of that point, and the warning actually goes to stdout. We
 should make sure that the warning goes to the log file.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/11770#comment:1>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list