[tor-commits] [stem/master] More succinct python 3 warning for parse_file()
atagar at torproject.org
atagar at torproject.org
Sun Feb 3 21:17:52 UTC 2013
commit 30146d77243f7a25d54019d9d2641be258c444f8
Author: Damian Johnson <atagar at torproject.org>
Date: Sun Feb 3 11:12:57 2013 -0800
More succinct python 3 warning for parse_file()
Read speeds and universal newline translation are both addressed by reading in
binary mode. There's no need to have a separate warning for each.
---
stem/descriptor/__init__.py | 18 ++++--------------
1 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/stem/descriptor/__init__.py b/stem/descriptor/__init__.py
index 0a7ee07..f99e3ca 100644
--- a/stem/descriptor/__init__.py
+++ b/stem/descriptor/__init__.py
@@ -83,20 +83,10 @@ def parse_file(descriptor_file, descriptor_type = None, path = None, validate =
tordnsel 1.0 **unsupported**
========================================= =====
- If you're using **python 3** then beware of the open() function's universal
- newline translation. By default open() converts all common line endings (NL,
- CR, and CRNL) into NL. In some edge cases this can cause us to misparse
- content. To disable newline translation set the **newline** to an empty
- string. For example...
-
- ::
-
- my_descriptor_file = open(descrptor_path, newline='')
-
- What's more, python 3's read performance in **text mode** is deplorably bad
- (my testing with python 3.2 shows it to be 33x slower). Using **binary mode**
- is strongly suggested. If you do this then newline translation is
- automatically disabled...
+ If you're using **python 3** then beware that the open() function defaults to
+ using **text mode**. **Binary mode** is strongly suggested because it's both
+ faster (by my testing by about 33x) and doesn't do universal newline
+ translation which can make us misparse the document.
::
More information about the tor-commits
mailing list