[issue20237] Ambiguous sentence in document of xml package.

2014-01-14 Thread Fran Bull

Fran Bull added the comment:

I think the sentence either means:
1) The courses of action that defusedxml implements are those recommended for 
any server code that parses untrusted XML data. 
or 
2) Using defused XML is recommended for any server code that parses untrusted 
XML data. 

And I think 2 is more likely. So the attached patch reflects that.

--
keywords: +patch
nosy: +Fran.Bull
Added file: http://bugs.python.org/file33465/20237.patch

___
Python tracker 
<http://bugs.python.org/issue20237>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20241] Bad reference to RFC in document of ipaddress?

2014-01-15 Thread Fran Bull

Fran Bull added the comment:

http://tools.ietf.org/html/rfc5735.html
Special Use IPv4 Addresses

does indeed agree with the docstring

@property
def is_unspecified(self):
"""Test if the address is unspecified.

Returns:
A boolean, True if this is the unspecified address as defined in
RFC 5735 3.

"""
unspecified_address = IPv4Address('0.0.0.0')
return self == unspecified_address

and makes more sense than http://tools.ietf.org/html/rfc5375.html
IPv6 Unicast Address Assignment Considerations

and so the attached patch will bring them into line.

However it's worth noting that the RFC doesn't say anything about 0.0.0.0 being 
the 'unspecified' address, (the RFC linked for the IPv6 is_unspecified 
http://tools.ietf.org/html/rfc2373.html#section-2.5.2 does specifically call it 
the 'unspecified' address). 5735 3 just says:

3.  Global and Other Specialized Address Blocks

   0.0.0.0/8 - Addresses in this block refer to source hosts on "this"
   network.  Address 0.0.0.0/32 may be used as a source address for this
   host on this network; other addresses within 0.0.0.0/8 may be used to
   refer to specified hosts on this network ([RFC1122], Section
   3.2.1.3).

googling it you can find eg this:

http://en.wikipedia.org/wiki/IPv6_address
says:
 ::/128 — The address with all zero bits is called the unspecified address 
(corresponding to 0.0.0.0/32 in IPv4).

so perhaps this bit of the docs could be a bit clearer, although I don't know 
what it should say, perhaps something like:
'Checks if the address is 0.0.0.0 which corresponds to the unspecified address 
in IPv6'
someone with better networking knowledge than me could say.

--
keywords: +patch
nosy: +Fran.Bull
Added file: http://bugs.python.org/file33482/20241.patch

___
Python tracker 
<http://bugs.python.org/issue20241>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20135] FAQ need list mutation answers

2014-01-16 Thread Fran Bull

Fran Bull added the comment:

I read the FAQ last night and I couldn't see these answered there either. I 
would like to try submitting a patch for this one, probably this evening. It 
will likely be two FAQs in the programming section that go something like:

Why does changing one list change another different list?
This happens:
>>> a = [1, 2, 3]
>>> b = a
>>> b.append(4)
>>> print a
[1, 2, 3, 4]

because variables are just names for things, in this case 'a' is the list we 
first defined and then b = a says that 'b' is also a name for that list. They 
are both the same list.

Why are my default args wrong?
This happens:

>>> from datetime import datetime
>>> class A(object):
...   def __init__(self, created_time=datetime.now()):
... self.created_time = created_time
... 
>>> an_a = A()
>>> another_a = A()
>>> an_a.created_time
datetime.datetime(2014, 1, 16, 10, 40, 54, 33283)
>>> another_a.created_time
datetime.datetime(2014, 1, 16, 10, 40, 54, 33283)

because default arguments are evaluated when they're read for the first time by 
the interpreter. Usually when the class is imported. A good way to get the 
above to do what you want is to use a default argument of None and check for 
it, like:
>>> class B(object):
...   def __init__(self, created_time=None):
... if created_time is None:
...   created_time=datetime.now()
... self.created_time = created_time
... 
>>> a_b = B()
>>> another_b = B()
>>> a_b.created_time
datetime.datetime(2014, 1, 16, 10, 44, 44, 956710)
>>> another_b.created_time
datetime.datetime(2014, 1, 16, 10, 44, 51, 71311)

Feedback appreciated, particularly I'm not sure if this:
'default arguments are evaluated when they're read for the first time by the 
interpreter'
is exactly the right language. I guess I'll look it up.

--
nosy: +Fran.Bull

___
Python tracker 
<http://bugs.python.org/issue20135>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20135] FAQ need list mutation answers

2014-01-16 Thread Fran Bull

Fran Bull added the comment:

Perhaps a 3rd FAQ something like this?:

Why is changing a list in one instance of a class also changing it in another 
instance of the same class?
This happens:
>>> class A(object):
...   def __init__(self, fruit=[]):
... self.fruit = fruit
... 
>>> an_A = A()
>>> an_A.fruit.append('apple')
>>> another_A = A()
>>> print another_A.fruit
['apple']
>>> another_A.fruit.append('banana')
>>> print another_A.fruit
['apple', 'banana']
>>> print an_A.fruit
['apple', 'banana']
>>> print an_A.fruit is another_A.fruit
True
>>> print an_A.fruit is A().fruit
True

because of a combination of the above two FAQs, first the default argument is 
evaluated when the 'def' statement is executed and creates an instance of list. 
After that new instances of A have a variable 'fruit' that is the name for that 
instance of list.

I'm not sure whether I should be using as general terms as possible for the Q, 
i.e. 'mutable object' instead of 'list'. I'll reread 
http://docs.python.org/devguide/documenting.html and the FAQs before writing 
the patch.

--

___
Python tracker 
<http://bugs.python.org/issue20135>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20135] FAQ need list mutation answers

2014-01-16 Thread Fran Bull

Changes by Fran Bull :


--
keywords: +patch
Added file: http://bugs.python.org/file33502/20135.patch

___
Python tracker 
<http://bugs.python.org/issue20135>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com