[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Remove hacks module and patch reduce_ex
commit 55e55a55a0365c3e4958482e315add4f0090243a
Author: Arturo Filastò <arturo@xxxxxxxxxxx>
Date: Sat Apr 23 19:03:49 2016 +0200
Remove hacks module and patch reduce_ex
* Delete benchmarks txt file
---
bin/ooniprobe | 7 ------
bin/ooniprobequeue | 5 -----
ooni/kit/benchmarks.txt | 35 -----------------------------
ooni/utils/hacks.py | 60 -------------------------------------------------
4 files changed, 107 deletions(-)
diff --git a/bin/ooniprobe b/bin/ooniprobe
index 31da086..4832d91 100755
--- a/bin/ooniprobe
+++ b/bin/ooniprobe
@@ -1,13 +1,6 @@
#!/usr/bin/env python
-import copy_reg
from twisted.internet import reactor
-# This is a hack to overcome a bug in python
-from ooni.utils.hacks import patched_reduce_ex
-copy_reg._reduce_ex = patched_reduce_ex
-
-# from ooni.oonicli import run
-# run()
from ooni.oonicli import runWithDirector
d = runWithDirector()
@d.addBoth
diff --git a/bin/ooniprobequeue b/bin/ooniprobequeue
index f81f156..88359e0 100755
--- a/bin/ooniprobequeue
+++ b/bin/ooniprobequeue
@@ -1,12 +1,7 @@
#!/usr/bin/env python
import sys
-import copy_reg
from twisted.internet import reactor
-# This is a hack to overcome a bug in python
-from ooni.utils.hacks import patched_reduce_ex
-copy_reg._reduce_ex = patched_reduce_ex
-
code=0
from ooni.oonicli import runWithDaemonDirector
diff --git a/ooni/kit/benchmarks.txt b/ooni/kit/benchmarks.txt
deleted file mode 100644
index c2070e5..0000000
--- a/ooni/kit/benchmarks.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-Read file B
-done in 0.74356508255
-Read file A
-done in 0.94336104393
-Computing prob matrix
-done in 0.0432229042053
-Computing eigenvalues
-done in 0.00188422203064
-Corelation: 0.999999079331
-
-
-Read file B
-done in 0.946599960327
-Read file A
-done in 0.909075975418
-Computing prob matrix
-done in 0.0541450977325
-Computing eigenvalues
-done in 0.00259518623352
-Computing prob matrix B
-done in 0.060467004776
-Computing eigen B
-done in 0.00102496147156
-Computing correlation
-done in 0.000158071517944
-Corelation: 0.999999079331
-
-this was with:
-683 filea.txt
-678 fileb.txt
-
-diff file* | wc -l
-283
-
-
diff --git a/ooni/utils/hacks.py b/ooni/utils/hacks.py
deleted file mode 100644
index 7ec3d0f..0000000
--- a/ooni/utils/hacks.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# When some software has issues and we need to fix it in a
-# hackish way, we put it in here. This one day will be empty.
-
-import copy_reg
-from twisted.web.client import SchemeNotSupported
-
-from txsocksx.http import SOCKS5Agent as SOCKS5AgentOriginal
-
-
-def patched_reduce_ex(self, proto):
- """
- This is a hack to overcome a bug in one of pythons core functions. It is
- located inside of copy_reg and is called _reduce_ex.
-
- Some background on the issue can be found here:
-
- http://stackoverflow.com/questions/569754/how-to-tell-for-which-object-attribute-pickle
- http://stackoverflow.com/questions/2049849/why-cant-i-pickle-this-object
-
- There was also an open bug on the pyyaml trac repo, but it got closed because
- they could not reproduce.
- http://pyyaml.org/ticket/190
-
- It turned out to be easier to patch the python core library than to monkey
- patch yaml.
-
- XXX see if there is a better way. sigh...
- """
- _HEAPTYPE = 1 << 9
- assert proto < 2
- for base in self.__class__.__mro__:
- if hasattr(base, '__flags__') and not base.__flags__ & _HEAPTYPE:
- break
- else:
- base = object # not really reachable
- if base is object:
- state = None
- elif base is int:
- state = None
- else:
- if base is self.__class__:
- raise TypeError("can't pickle %s objects" % base.__name__)
- state = base(self)
- args = (self.__class__, base, state)
- try:
- getstate = self.__getstate__
- except AttributeError:
- if getattr(self, "__slots__", None):
- raise TypeError("a class that defines __slots__ without "
- "defining __getstate__ cannot be pickled")
- try:
- dict = self.__dict__
- except AttributeError:
- dict = None
- else:
- dict = getstate()
- if dict:
- return copy_reg._reconstructor, args, dict
- else:
- return copy_reg._reconstructor, args
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits