Re: Floating point overflow and underflow

2020-01-07 Thread Shashank Tiwari
Oh, thanks. Didn't think of that. On Tue, Jan 7, 2020, 7:53 PM Michael Torrie wrote: > On 1/7/20 8:46 PM, Shashank Tiwari wrote: > > Yes, I tried this and it worked. I was wondering if I could use the > output > > of pow (or math.pow). > > Sure: > > pow

Re: Floating point overflow and underflow

2020-01-07 Thread Shashank Tiwari
Thanks everyone. Much appreciated. On Tue, Jan 7, 2020, 7:46 PM Shashank Tiwari wrote: > Yes, I tried this and it worked. I was wondering if I could use the output > of pow (or math.pow). > > On Tue, Jan 7, 2020, 7:41 PM Michael Torrie wrote: > >> On 1/7/20 8:18 PM,

Re: Floating point overflow and underflow

2020-01-07 Thread Shashank Tiwari
Yes, I tried this and it worked. I was wondering if I could use the output of pow (or math.pow). On Tue, Jan 7, 2020, 7:41 PM Michael Torrie wrote: > On 1/7/20 8:18 PM, Shashank Tiwari wrote: > > Thanks Chris. What if it's pow(2.2,0.45)? > > Why not do some more experimentation:

Re: Floating point overflow and underflow

2020-01-07 Thread Shashank Tiwari
Thanks Chris. What if it's pow(2.2,0.45)? On Tue, Jan 7, 2020, 6:40 PM Chris Angelico wrote: > On Wed, Jan 8, 2020 at 1:37 PM Shashank Tiwari > wrote: > > > > Thanks Rob. > > > > How would one initialize a Decimal with something like pow(2,256)? > > > >

Re: Floating point overflow and underflow

2020-01-07 Thread Shashank Tiwari
Thanks Rob. How would one initialize a Decimal with something like pow(2,256)? On Tue, Jan 7, 2020 at 5:25 PM Rob Gaddi wrote: > On 1/7/20 3:47 PM, Shashank Tiwari wrote: > > In Python3 an operation as follows: > >>>> 10135.1941 * (10**8) > > gives

Floating point overflow and underflow

2020-01-07 Thread Shashank Tiwari
In Python3 an operation as follows: >>> 10135.1941 * (10**8) gives the result: 101351941.0001 Similarly, using the pow function also gives the same overflow/underflow error. >>> 10135.1941 * pow(10,8) 101351941.0001 Like multiplication, division of large or very small floating point

[issue21109] tarfile: Traversal attack vulnerability

2018-10-09 Thread shashank
shashank added the comment: It won't exactly be drop-in replacement. I mean if users decide to replace Tarfile with SafeTarFile, existing code may break since there might be cases where dodgy tarballs are acceptable and/or used then SafeTarFile.open will throw an exception. Having said

[issue21109] tarfile: Traversal attack vulnerability

2018-09-26 Thread shashank
shashank added the comment: Added tests. Patch file: safetarfile-4.diff Following works with 456 tests passed, after doing `make clean && make` # ./python -m unittest -v test.test_tarfile Attached patch is on top of master's commit: commit 2aaf98c16ae3070378de523a173e29644037d8

[issue21109] tarfile: Traversal attack vulnerability

2018-09-17 Thread shashank
shashank added the comment: I can't use Jakub's repo (or Makefile from that repo) directly because it relies on tar, which doesn't look like dependency for building Python. I can make similar tarballs but I am not sure how licensing will work. I can add tarballs for the cases I discovered

[issue21109] tarfile: Traversal attack vulnerability

2018-09-14 Thread shashank
shashank added the comment: Figured a fix for the bug I found, trick was to keep track of current working dir of symlink it was trying to evaluate. Attached patch: safetarfile-3.diff Patch is for code only. I'd like to see this go thorough, and would appreciate feedback. -- Added

[issue21109] tarfile: Traversal attack vulnerability

2018-09-12 Thread shashank
shashank added the comment: 1. I have done some changes to Lar's patch to address class of bugs which Jakub found. Attached patch safetarfile-2.diff Patch is for code only and is work in progress. 2. However, there maybe several edge cases which have not been covered. Going by types

[issue21109] tarfile: Traversal attack vulnerability

2018-09-09 Thread shashank
shashank added the comment: A. Regrading Jakub's tests, I suppose the changes needed are to for every name in tar i) find reasonable occurrence of symlink's name and replace it with smylink's linkname ii) convert it to normal path and then check for relative / absolute paths B. Jakub

[issue26296] colorys rgb_to_hls algorithm error

2016-02-05 Thread Shashank Agarwal
Shashank Agarwal added the comment: I would like to work on this.. -- nosy: +The_Knight ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

Re: use Python to post image to Facebook

2012-04-10 Thread Shashank Singh
of which apparently Forgot the refs: [1]https://github.com/facebook/fbconsole; http://blog.carduner.net/2011/09/06/easy-facebook-scripting-in-python/ [2]https://github.com/jgorset/facepy -- http://mail.python.org/mailman/listinfo/python-list -- Regards Shashank Singh http

Re: How to filter a dictionary ?

2012-04-10 Thread Shashank Singh
value pairs -- Regards Shashank Singh http://www.flipora.com http://r http://www.cse.iitb.ac.in/~shashanksinghationalpie.wordpress.com -- http://mail.python.org/mailman/listinfo/python-list

Re: How to filter a dictionary ?

2012-04-10 Thread Shashank Singh
On Tue, Apr 10, 2012 at 12:16 AM, Dave Angel d...@davea.name wrote: On 04/10/2012 02:04 AM, Shashank Singh wrote: On Mon, Apr 9, 2012 at 10:49 PM, Nikhil Verma varma.nikhi...@gmail.com wrote: SNIP I am trying this but its giving me a generator object. In [9]: (k for k,v

Re: Default value for optional parameters unexpected behaviour?

2011-06-26 Thread Shashank Singh
to [] by checking for None inside the function def f(a=None): if a is None: a = [] -- Regards Shashank Singh http://rationalpie.wordpress.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to insert sorted in a list

2011-06-17 Thread Shashank Singh
in a list ? -- http://mail.python.org/mailman/listinfo/python-list -- Regards Shashank Singh http://www.cse.iitb.ac.in/~shashanksingh -- http://mail.python.org/mailman/listinfo/python-list

Re: How to stop iteration

2011-06-05 Thread Shashank Singh
', 'le', ' p', 'yt', 'ho', 'n ', 'pr', 'og', 'ra', 'mm', 'in', 'g'] In this case you are actually using the return values (and not changing a global variable). HTH -- Regards Shashank Singh http://www.cse.iitb.ac.in/~shashanksingh -- http://mail.python.org/mailman/listinfo/python-list

Re: Final state of underlying sequence in islice

2010-11-06 Thread Shashank Singh
sure that the parameters are such that such cases don't arise but I would still like to see python doing the best possible thing as far as possible. -- Regards Shashank Singh shashank.sunny.si...@gmail.com http://www.cse.iitb.ac.in/~shashanksinghhttp://www.cse.iitb.ac.in/%7Eshashanksingh

[issue10323] Final state of underlying sequence in islice

2010-11-05 Thread Shashank
New submission from Shashank shashank.sunny.si...@gmail.com: -- Converting the discussion here http://mail.python.org/pipermail/python-list/2010-November/1259601.html to a bug report (+nosy for everyone that responded, quoting the initial message for context) Are there any promises made

[issue10323] Final state of underlying sequence in islice

2010-11-05 Thread Shashank
Shashank shashank.sunny.si...@gmail.com added the comment: @Raymond: I don't have a particular use case where I had a problem with this behavior. I came across this problem when looking at this issue http://bugs.python.org/issue6305. An important problem that can happen with this behavior

Final state of underlying sequence in islice

2010-11-04 Thread Shashank Singh
://docs.python.org/library/itertools.html#itertools.islice -- Regards Shashank Singh shashank.sunny.si...@gmail.com http://www.cse.iitb.ac.in/~shashanksinghhttp://www.cse.iitb.ac.in/%7Eshashanksingh -- http://mail.python.org/mailman/listinfo/python-list

[issue10030] Patch for zip decryption speedup

2010-11-04 Thread Shashank
Shashank shashank.sunny.si...@gmail.com added the comment: I had uploaded an incorrect patch. New corrected patch against trunk (on Mac OS uploaded). -- Added file: http://bugs.python.org/file19494/zipdecrypt.patch ___ Python tracker rep

[issue10030] Patch for zip decryption speedup

2010-11-04 Thread Shashank
Changes by Shashank shashank.sunny.si...@gmail.com: Removed file: http://bugs.python.org/file19494/zipdecrypt.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10030

[issue10030] Patch for zip decryption speedup

2010-11-04 Thread Shashank
Changes by Shashank shashank.sunny.si...@gmail.com: Added file: http://bugs.python.org/file19495/zipdecrypt.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10030

[issue10030] Patch for zip decryption speedup

2010-10-23 Thread Shashank
Shashank shashank.sunny.si...@gmail.com added the comment: the C module should be private and therefore called _zipdecrypt done if you want to avoid API mismatch, you could give a tp_call to your C decrypter object, rather than a decrypt method done - you can put all initialization code

[issue10030] Patch for zip decryption speedup

2010-10-12 Thread Shashank
Shashank shashank.sunny.si...@gmail.com added the comment: Attached is a patch with changes in Lib/test/test_zipfile.py to test both C and pure-py impls (on systems where the C impl is present). Admittedly, this approach to emulating the absence of C impl is a bit hacky. This is primarily

[issue10030] Patch for zip decryption speedup

2010-10-12 Thread Shashank
Changes by Shashank shashank.sunny.si...@gmail.com: Added file: http://bugs.python.org/file19197/zipdecrypt.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10030

[issue10030] Patch for zip decryption speedup

2010-10-07 Thread Shashank
Shashank shashank.sunny.si...@gmail.com added the comment: I have updated the patch with a check for the availability of C impl and to use pure-py impl as a fallback. How do you suggest would the tests change? As I had mentioned before, in my understanding since there is no change in the API

[issue10030] Patch for zip decryption speedup

2010-10-05 Thread Shashank
New submission from Shashank shashank.sunny.si...@gmail.com: As promised in this thread http://mail.python.org/pipermail/python-dev/2009-August/091450.html (a year ago!), attached is a patch that replaces simple zip decryption logic written in pure python with that in C. As reported

Re: That interesting notation used to describe how long a loop will take.

2010-10-04 Thread Shashank Singh
a concise name. Thanks, Tobiah -- http://mail.python.org/mailman/listinfo/python-list -- Regards Shashank Singh shashank.sunny.si...@gmail.com http://www.cse.iitb.ac.in/~shashanksinghhttp://www.cse.iitb.ac.in/%7Eshashanksingh -- http://mail.python.org/mailman/listinfo/python-list

Re: Reversing a List

2010-09-01 Thread Shashank Singh
-list -- Regards Shashank Singh Senior Undergraduate, Department of Computer Science and Engineering Indian Institute of Technology Bombay shashank.sunny.si...@gmail.com http://www.cse.iitb.ac.in/~shashanksingh -- http://mail.python.org/mailman/listinfo/python-list

Re: Two minor questions on Class

2010-07-30 Thread Shashank Singh
On Fri, Jul 30, 2010 at 10:53 PM, joy99 subhakolkata1...@gmail.com wrote: class Person(object): def _init_(self,name,age): self.name=name self.age=age constructor has double underscores (both as prefix and suffix) __init__ -- Regards Shashank Singh

Fastest way to apply a function to an iterable

2010-05-26 Thread Shashank Singh
suggestions will be appreciated. TIA -- Regards Shashank Singh Senior Undergraduate, Department of Computer Science and Engineering Indian Institute of Technology Bombay shashank.sunny.si...@gmail.com http://www.cse.iitb.ac.in/~shashanksingh -- http://mail.python.org/mailman/listinfo/python-list

Re: Fastest way to apply a function to an iterable

2010-05-26 Thread Shashank Singh
/imap. Another problem with map/imap is that the memory cost is dependent on the length of the list (because of the intermediate mapped list stored) which is not the case for simple for loop. I hope I have explained it better this time. -- Regards Shashank Singh Senior Undergraduate, Department

Re: Help regarding XML file manipulation

2010-05-25 Thread Shashank Singh
the value of nodes will not automatically do that. HTH -S Thanks ~S -- http://mail.python.org/mailman/listinfo/python-list -- Regards Shashank Singh Senior Undergraduate, Department of Computer Science and Engineering Indian Institute of Technology Bombay shashank.sunny.si...@gmail.com

Re: an element from a set

2010-05-15 Thread Shashank Singh
-- Regards Shashank Singh Senior Undergraduate, Department of Computer Science and Engineering Indian Institute of Technology Bombay shashank.sunny.si...@gmail.com http://www.cse.iitb.ac.in/~shashanksingh -- http://mail.python.org/mailman/listinfo/python-list

Re: Fastest way to calculate leading whitespace

2010-05-08 Thread Shashank Singh
of solutions people might have. Thanks, Daniel -- http://mail.python.org/mailman/listinfo/python-list -- Regards Shashank Singh Senior Undergraduate, Department of Computer Science and Engineering Indian Institute of Technology Bombay shashank.sunny.si...@gmail.com http://www.cse.iitb.ac.in

Re:

2010-05-01 Thread Shashank Singh
then it should write that as doubtful and rest it should write as error. Thanks, -- http://mail.python.org/mailman/listinfo/python-list -- Regards Shashank Singh Senior Undergraduate, Department of Computer Science and Engineering Indian Institute of Technology Bombay shashank.sunny.si

Re: Help needed in downloading Brown corpus

2010-05-01 Thread Shashank Singh
how to solve my downloading problem or how to get Brown Corpus from some other link. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list -- Regards Shashank Singh Senior Undergraduate, Department of Computer Science and Engineering Indian Institute of Technology Bombay

Re: Behavior of default parameter in a function

2010-03-11 Thread Shashank Singh
and is modified with each call. hth --shashank On Thu, Mar 11, 2010 at 3:02 PM, jitendra gupta jitu.ic...@gmail.comwrote: def foo(x = [0]): x[0] = x[0] + 1 return x[0] def soo(x = None): if x is None: x = [0] x[0] = x[0] + 1 return x[0] foo() 1 foo() #See the behavior incremented by one 2

Re: Too Many Values To Unpack

2009-11-20 Thread Shashank Singh
, level = 0): MAXLEVEL = 7 if level MAXLEVEL: return #possibly the data has a cycle/loop for (nm, dt) in levelDict: Are you sure your key values are 2-tuples in levelDict? For-each on dicts enumerates the keys AFAIK -- Regards Shashank Singh Senior Undergraduate, Department of Computer

(Simple?) Unicode Question

2009-08-27 Thread Shashank Singh
of a piece of text? I mean, as long as we are not trying to get a symbolic representation of a text or get ith character of it, all we need to do is to carry the intended encoding as an auxiliary information to the data stored as byte array. Right? --shashank -- http://mail.python.org/mailman

[issue5007] urllib2 HTTPS connection failure (BadStatusLine Exception)

2009-08-22 Thread Shashank
Shashank shashank.sunny.si...@gmail.com added the comment: Works fine for me in 2.6 but fails as said by OP on 2.5. (I came across this in the course of my work and am submitting a change in a bug for the first time, pardon me if something is inappropriate :) I used this modified codeblock