[issue8174] Misleading reported number of given arguments on function call TypeError

2010-03-18 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: The following exception message seems misleading, or at least not obvious: def f(a,b,c): pass ... f(c=0,a=0) Traceback (most recent call last): File stdin, line 1, in module TypeError: f() takes exactly 3 non-keyword arguments (1

[issue3135] inspect.getcallargs()

2010-03-18 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: I reverted the function to the original API (return just the dict with the bindings), cleaned it up, wrote thorough unit tests and made a patch against Python 2.7a4. -- keywords: +patch Added file: http://bugs.python.org

[issue3135] inspect.getcallargs()

2010-03-19 Thread George Sakkis
Changes by George Sakkis george.sak...@gmail.com: Removed file: http://bugs.python.org/file16579/getcallargs.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3135

[issue3135] inspect.getcallargs()

2010-03-19 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Renamed the Testcase classes to conform with the rest in test_inspect.py, added a few more tests for tuple args and patched against the latest trunk (r79086). -- Added file: http://bugs.python.org/file16587/getcallargs.patch

[issue6474] Inconsistent TypeError message on function calls with wrong number of arguments

2010-03-19 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Which version are you running ? I don't get the positional word in 2.6 and 2.7a4. In my opinion it should report how many required arguments are passed, regardless of how they are passed (positionally or by name). So in your example

[issue6474] Inconsistent TypeError message on function calls with wrong number of arguments

2010-03-19 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Attached patch for displaying the number of missing required arguments. -- keywords: +patch Added file: http://bugs.python.org/file16589/6474.patch ___ Python tracker rep...@bugs.python.org

[issue3135] inspect.getcallargs()

2010-03-19 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: - Added docs in inspect.rst - Fixed TypeError message for zero-arg functions (takes no arguments instead of takes exactly 0 arguments) + added test. -- Added file: http://bugs.python.org/file16591/getcallargs2.patch

[issue3135] inspect.getcallargs()

2010-03-19 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Uploaded at http://codereview.appspot.com/659041/show -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3135

[issue1745] Backport of PEP 3102 keyword-only arguments to 2.6

2010-03-21 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Is there any update on this for 2.7 ? -- nosy: +gsakkis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1745

[issue1745] Backport of PEP 3102 keyword-only arguments to 2.6

2010-03-21 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: FWIW I updated the patch to r79264; it applies cleanly and passes the tests but other than that I can't tell if it's ready. It would be nice to have it in 2.7 though. -- Added file: http://bugs.python.org/file16618/backport

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2010-04-15 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Just bitten by this (through a 3rd party library that uses this pattern) and I'm wondering why it was closed as invalid. Passing a non-empty fromlist string also imports the tail module but without the side effect of double import, so

[issue2090] __import__ with fromlist=

2010-04-15 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: When you use an empty string in fromlist you are essentially simulating ``from pkg import`` which makes absolutely no sense, so no one has cared enough to try to fix this. ``from pkg import __bogus__, 123, @$%`` doesn't make sense

[issue2090] __import__ with fromlist=

2010-04-15 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: More fun findings: dots are special-cased too, but only if they don't appear consecutively (!); ~$ cat pkg/__init__.py print __name__ ~$ python -c __import__('pkg', fromlist=['.']) pkg pkg.. ~$ python -c __import__('pkg', fromlist

[issue2090] __import__ with fromlist=

2010-04-18 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: FWIW attached is a patch that allows only valid identifiers before calling import_submodule(), and returns silently otherwise (for backwards compatibility). For the record, the reason that empty strings and some combinations of slashes

[issue2090] __import__ with fromlist=

2010-04-18 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: On the surface this seems like a potential directory traversal attack hole, although I couldn't get past 'pkg' by passing '../../../', so I guess there must be other checks before attempting the import. I rushed to post; it turns out

[issue2831] Adding start to enumerate()

2010-05-05 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Just discovered this by chance; I would probably have noticed it earlier if the docstring had been updated. Let me know if it needs a new documentation bug ticket and I'll create one. Pretty handy feature by the way, thanks for adding

[issue3135] inspect.getcallargs()

2008-06-18 Thread George Sakkis
New submission from George Sakkis [EMAIL PROTECTED]: I'd like to propose a new function for inclusion to the inspect module -- getcallargs(func, *args, **kwds) -- that returns a dict which maps the formal arguments of a function (or other callable) to the values passed as args and kwds, just

[issue2279] distutils sdist add_defaults does not add data_files

2009-02-13 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: I didn't mean to imply that automagic discovery based on external version control software is better than MANIFEST.in; I favor explicitness here as well. It's just that this information can (and often has to) be duplicated in setup.py

[issue2279] distutils sdist add_defaults does not add data_files

2009-02-15 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: By an equivalent option in setup() of course. I'm not against the *functionality* of MANIFEST.in but on that (a) it's a second file you have to remember to write and maintain in addition to setup.py (b) has its own ad-hoc syntax instead

[issue2279] distutils sdist add_defaults does not add data_files

2009-02-16 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: FWIW I wrote a module that overrides the default build_py and sdist commands with versions that allow specifying package_data recursively Maybe that could be a new feature ? That would be nice, especially if we want to reimplement

[issue2279] distutils sdist add_defaults does not add data_files

2009-02-16 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: done in r69692 and r69696. Great, thanks. The data_files part though seems incorrect; for one thing each item in data_files can be either a (dir,files) tuple or a plain string, and for two 'dir' is the output (installation) directory

[issue5300] Distutils ignores file permissions

2009-02-17 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: Distutils ignores file permissions when copying modules and package_data files to the build directory, and consequently to the installation directory too. According to an XXX comment at distutils/command/build_py.py, this is deliberate

[issue5302] Allow package_data globs match directories

2009-02-17 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: Currently each glob defined in package_data must match files only; if it matches a directory, it raises an exception later when calling copy_file(). This means that a glob like 'mydata/*' will fail if there is any subdirectory under

[issue2279] distutils sdist add_defaults does not add data_files

2009-02-17 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Opened #5300 and #5302 for the mentioned issues. Btw in your patch, I believe `os.path.join(dirname, f)` should be replaced by `f` alone; `dirname` refers to the dir under the installation directory, not the source

[issue5302] Allow package_data globs match directories

2009-02-18 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: I am no in favor of MANIFEST.in removal because I find it very convenient to define what is included in a package and I rarely use package_data or data_files. AFAIK the MANIFEST is used only by sdist; what's the point of including

[issue5300] Distutils ignores file permissions

2009-02-18 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: what is your use case of having executable file here ? I'd use the 'scripts' metadata for that ? For one thing they are external binaries, not python scripts, and second they are used internally only (through Subprocess

[issue5669] Extra heap nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: It would be useful in many cases if heapq.nlargest and heapq.nsmallest grew an optional boolean parameter, say `ties` (defaulting to False) that when True, it would return more than `n` items if there are ties. To illustrate: s

[issue5669] Extra heap nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: The second call should of course be: for i in xrange(1,len(s)+1): print i,heapq.nsmallest(i,s,ties=True) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5669

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
Changes by George Sakkis george.sak...@gmail.com: -- title: Extra heap nlargest/nsmallest option for including ties - Extra heapq nlargest/nsmallest option for including ties ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5669

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: There's nothing special about my use cases; I'd even go as far as to suggest that this is more often than not the desired behavior in general. Say that you have to select the top 3 chess players and there are two players with equal Elo

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: In that case, I think it best to leave nsmallest/nlargest as-is. By appending ties to the result, it becomes harder to implement policy decisions on what to do with those ties (perhaps listing them separately or splitting

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: That should have been: last = result[-1]; [last]*s.count(last). Nice, though that's not equivalent if the objects' identity is significant for what happens next (which typically is the case when ties are preserved). The sorted/bisect

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
Changes by George Sakkis george.sak...@gmail.com: -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5669 ___ ___ Python-bugs

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: I recommend posting an ASPN recipe. That's what I do with a lot of ideas that are under development or that don't clear the bar for going into the standard library. Will do. Thanks for the quick turnaround

[issue5697] heapq.nlargest does not perform stable sort

2009-04-05 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: According to the docs, heapq.nlargest should be equivalent to sorted(iterable, key=key, reverse=True)[:n], and since sorted() is stable, so should heapq.nlargest be. This is not the case: s =[ ('Mike', -1), ('John', 3), ('George', 2

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-05 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Posted recipe at http://code.activestate.com/recipes/576712/. You were right, the implementation gets significantly hairier but I think it's worth having this option. It's also faster than using sorted/bisect as len(seq)/N increases

[issue5697] heapq.nlargest does not perform stable sort

2009-04-05 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Should have checked a recent version first; that's from 2.5 (r25:51908, Sep 19 2006, 09:52:17). Sorry for the noise. -- status: open - closed ___ Python tracker rep...@bugs.python.org http

[issue5890] Subclassing property doesn't preserve the auto __doc__ behavior

2009-04-30 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: Is the following behavior expected ? class MyProp(property): pass class Foo(object): @property def bar(self): '''Get a bar.''' @MyProp def baz(self): '''Get a baz.''' print Foo.bar.__doc__

[issue5982] classmethod, staticmethod: expose wrapped function

2009-05-09 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: It would be nice if classmethod/staticmethod exposed the wrapped function as a read-only attribute/property. Currently the function can be retrieved indirectly but it's obscure (and perhaps not always correct, I'm not sure): In [147

[issue3135] inspect.getcallargs()

2009-05-14 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: I updated the recipe to also return a `missing_args` tuple - the tuple of the formal parameters whose value was not provided. This is useful in cases where one want to distinguish f() from f(None) given def f(x=None). -- versions

[issue3135] inspect.getcallargs()

2009-05-14 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Also updated url: http://code.activestate.com/recipes/551779/ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3135

[issue5982] classmethod, staticmethod: expose wrapped function

2009-05-19 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: I don't remember the exact use case but it had to do with making a decorator robust enough to work for different kinds of callables (and a few common non-callables such as classmethod/staticmethod). It's not a show stopper by any means

[issue36662] asdict/astuple Dataclass methods

2019-04-18 Thread George Sakkis
New submission from George Sakkis : I'd like to propose two new optional boolean parameters to the @dataclass() decorator, `asdict` and `astuple`, that if true, the respective methods are generated as equivalent to the module-level namesake functions. In addition to saving an extra imported

[issue36662] asdict/astuple Dataclass methods

2019-04-19 Thread George Sakkis
George Sakkis added the comment: > I think the best thing to do is write another decorator that adds this > method. I've often thought that having a dataclasses_tools third-party module > would be a good idea. I'd be happy with a separate decorator in the standard library f

[issue42409] Interpreter exit blocks waiting for ThreadPoolExecutor.map

2020-11-19 Thread George Sakkis
New submission from George Sakkis : ThreadPoolExecutor.map() prevents interpreter exit if there is a reference to the generator it returns. In the attached script: - `python threadpool_map.py run1` exits as soon as the exception is raised on the main thread. This is the desired behavior