[Patches] [ python-Patches-487906 ] update inline docs in stringobject.c
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 10 Jan 2002 17:48:50 -0800
Patches item #487906, was opened at 2001-12-01 12:42
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=487906&group_id=5470
Category: None
Group: None
>Status: Open
Resolution: Accepted
Priority: 5
Submitted By: Zooko Ozoko (zooko)
Assigned to: Nobody/Anonymous (nobody)
Summary: update inline docs in stringobject.c
Initial Comment:
--- Objects/stringobject.c 2001/11/28 20:27:42
2.141
+++ Objects/stringobject.c 2001/12/01 20:40:09
@@ -19,19 +19,26 @@
#endif
/*
- Newsizedstringobject() and newstringobject() try in
certain cases
+ PyString_FromStringAndSize() and
PyString_FromString() try in certain cases
to share string objects. When the size of the
string is zero,
these routines always return a pointer to the same
string object;
when the size is one, they return a pointer to an
already existing
object if the contents of the string is known. For
- newstringobject() this is always the case, for
- newsizedstringobject() this is the case when the
first argument in
+ PyString_FromString() this is always the case, for
+ PyString_FromStringAndSize() this is the case when
the first argument in
not NULL.
- A common practice to allocate a string and then
fill it in or
- change it must be done carefully. It is only
allowed to change the
- contents of the string if the obect was gotten from
- newsizedstringobject() with a NULL first argument,
because in the
+ A common practice of allocating a string and then
filling it in or
+ changing it must be done carefully. It is only
allowed to change the
+ contents of the string if the object was gotten from
+ PyString_FromStringAndSize() with a NULL first
argument, because in the
future these routines may try to do even more
sharing of objects.
+
+ The parameter `size' denotes number of characters
in the string, not number
+ of bytes requires to store it, and does not count
the null terminating
+ character.
+
+ On the other hand, the member `op->ob_size' denotes
the number of bytes
+ used for storing the string, including the null
terminating character.
*/
PyObject *
PyString_FromStringAndSize(const char *str, int size)
@@ -58,7 +65,7 @@
----------------------------------------------------------------------
>Comment By: Zooko Ozoko (zooko)
Date: 2002-01-10 17:48
Message:
Logged In: YES
user_id=52562
reopening for new version of docs
----------------------------------------------------------------------
Comment By: Zooko Ozoko (zooko)
Date: 2002-01-10 17:46
Message:
Logged In: YES
user_id=52562
Hi, I have updated these docs one last time, throwing out
all the original docs and rewriting. Now I am happy with them.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2001-12-03 00:25
Message:
Logged In: YES
user_id=21627
Even though this comment is right, it now reads as a
contradiction, since two sentences later, it says
If the `str' argument is not NULL, then it must point to a
null-terminated string of length `size'.
I've reformulated this somewhat, and commmitted your text.
----------------------------------------------------------------------
Comment By: Zooko Ozoko (zooko)
Date: 2001-12-02 10:50
Message:
Logged In: YES
user_id=52562
Here's one more addition to the in-line docs. I was trying
to optimize `PyString_FromStringAndSize()' and I broke it
because I didn't realize this fact, so I added this fact to
the docs. :-)
(pasted and attached)
--- Objects/stringobject.c 2001/12/02 18:09:41 2.142
+++ Objects/stringobject.c 2001/12/02 18:47:48
@@ -33,6 +33,10 @@
a NULL first argument, because in the future these
routines may try to do
even more sharing of objects.
+ The string in the `str' parameter does not have to be
null-character
+ terminated. (Therefore it is safe to construct a
substring by using
+ `PyString_FromStringAndSize(origstring, substrlen)'.)
+
The parameter `size' denotes number of characters to
allocate, not counting
the null terminating character. If the `str' argument
is not NULL, then it
must point to a null-terminated string of length `size'.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2001-12-02 10:10
Message:
Logged In: YES
user_id=21627
It's not just upload that is difficult; download has its
speed bumps as well. Mozilla insists to call all files
downloaded from SF "download.php", no matter what filename
SF has recorded...
Thanks for the patch; it is in stringobject.c 2.142.
----------------------------------------------------------------------
Comment By: Zooko Ozoko (zooko)
Date: 2001-12-02 08:47
Message:
Logged In: YES
user_id=52562
Heh heh heh. I can't wait for the day that we can remotely
collaborate with something other than a web browser as the
user interface. Okay, sorry, here is a newer version of the
patch.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2001-12-02 07:34
Message:
Logged In: YES
user_id=21627
There is currently nothing attached.
----------------------------------------------------------------------
Comment By: Zooko Ozoko (zooko)
Date: 2001-12-01 12:44
Message:
Logged In: YES
user_id=52562
Okay I guess that's all mangled. DAMN, I hate trying to use
a web browser for anything other than browsing.
Anyway, I've attached the same patch.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=487906&group_id=5470