Skip to content

Instantly share code, notes, and snippets.

View ironpythonbot's full-sized avatar

ironpythonbot

View GitHub Profile
@ironpythonbot
ironpythonbot / ConsoleManager.cs
Created December 9, 2014 18:17
CodePlex Issue #35688 Plain Text Attachments
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
namespace MyConsole
{
/// <summary>
/// Do ConsoleManager.Show() followed by Console.WritLine(), etc
@ironpythonbot
ironpythonbot / clrtype.py
Created December 9, 2014 18:15
CodePlex Issue #35457 Plain Text Attachments
#####################################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# This source code is subject to terms and conditions of the Microsoft Public License. A
# copy of the license can be found in the License.html file at the root of this distribution. If
# you cannot locate the Microsoft Public License, please send an email to
# ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
# by the terms of the Microsoft Public License.
#
@ironpythonbot
ironpythonbot / send_signal.py
Created December 9, 2014 18:13
CodePlex Issue #35020 Plain Text Attachments
from subprocess import Popen, CREATE_NEW_PROCESS_GROUP
import ctypes
import signal
import sys
import time
def receive():
def handler(signum, frame):
@ironpythonbot
ironpythonbot / test5.py
Created December 9, 2014 18:13
CodePlex Issue #34968 Plain Text Attachments
from functools import partial
class _MetaBaseObject(type):
def __init__(cls, name, bases, dct):
super(_MetaBaseObject, cls).__init__(name, bases, dct)
class Attr:
def __init__(self, **kwargs):
for k,v in kwargs.items():
setattr(self,k,v)
@ironpythonbot
ironpythonbot / overflowTest.py
Created December 9, 2014 18:12
CodePlex Issue #34760 Plain Text Attachments
import random
class Item:
def __init__(self, id):
self.Id = id
self.Value = random.random() * random.randint(5,100)
self.IsGood = random.random() < 0.9 # ~90% good
x = map(lambda i: Item(i), range(0, 1000))
@ironpythonbot
ironpythonbot / struct_tests.py
Created December 9, 2014 18:11
CodePlex Issue #34682 Plain Text Attachments
import unittest
import struct
import array
class StructTest(unittest.TestCase):
def test_unpack(self):
# test string format string
result = struct.pack(">HH", 1, 2)
self.assertEqual(result, b"\x00\x01\x00\x02")
@ironpythonbot
ironpythonbot / bom.py
Created December 9, 2014 18:11
CodePlex Issue #34655 Plain Text Attachments
from __future__ import with_statement
from codecs import BOM_UTF8
with open('with_bom.txt', 'w') as f:
f.write(BOM_UTF8 + u'\xe4'.encode('UTF-8'))
with open('without_bom.txt', 'w') as f:
f.write(u'\xe4'.encode('UTF-8'))
with open('with_bom.txt') as f:
@ironpythonbot
ironpythonbot / Program.cs
Created December 9, 2014 18:10
CodePlex Issue #34602 Plain Text Attachments
namespace IPyImports
{
using IronPython.Hosting;
class Program
{
static void Main(string[] args)
{
var e = Python.CreateEngine();
@ironpythonbot
ironpythonbot / zipimport.path
Created December 9, 2014 18:10
CodePlex Issue #34571 Plain Text Attachments
*** D:/Tmp/~/2/zipimport.cs Thu Oct 17 18:25:24 2013
--- D:/Tmp/~/1/zipimport.cs Thu Nov 07 10:49:37 2013
***************
*** 212,224 ****
PythonContext pythonContext = PythonContext.GetContext(context);
PythonDictionary dict;
ScriptCode script = null;
! string code = GetModuleCode(context, fullname, out ispackage, out modpath);
if (code == null) {
return null;
@ironpythonbot
ironpythonbot / test_traceback.py
Created December 9, 2014 18:09
CodePlex Issue #34386 Plain Text Attachments
import unittest, sys, traceback
class TestTraceback(unittest.TestCase):
def test_truncate_traceback_with_typeerror(self):
def task3():
return (1, 2) + [3, 4] # TypeError
def task2():
task3()